Skip to content

Commit c1c4285

Browse files
authored
test: fix messages checking (#59)
1 parent 95f9dd0 commit c1c4285

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

test/unit/cloud_logging.test.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const tap = require('tap')
2-
const { satisfies } = require('semver')
32

43
const { CloudLogging } = require('../../lib/cloud-logging')
54

@@ -973,11 +972,7 @@ tap.test('CloudLogging#sync', root => {
973972
async t => {
974973
let expectedEntry
975974
const expectedLogEntry = {
976-
error: !satisfies(process.versions.node, '>=20.x')
977-
? new SyntaxError('Unexpected token { in JSON at position 1')
978-
: new SyntaxError(
979-
"Expected property name or '}' in JSON at position 1"
980-
),
975+
error: new SyntaxError('Unexpected token { in JSON at position 1'),
981976
message: 'Malformed log entry'
982977
}
983978
class LogMock extends BaseLogMock {
@@ -994,7 +989,8 @@ tap.test('CloudLogging#sync', root => {
994989
)
995990

996991
t.same(meta, expectedMeta)
997-
t.same(log, expectedLogEntry)
992+
t.same(log.message, 'Malformed log entry')
993+
t.type(log.error, SyntaxError)
998994

999995
return (
1000996
(expectedEntry = Object.assign({}, meta, {
@@ -1029,7 +1025,7 @@ tap.test('CloudLogging#sync', root => {
10291025
'@google-cloud/logging': { Logging: LoggingMock }
10301026
})
10311027

1032-
t.plan(3)
1028+
t.plan(4)
10331029

10341030
const instance = new CloudLogging(logName, defaultOptions)
10351031

@@ -1887,11 +1883,7 @@ tap.test('CloudLogging#async', root => {
18871883
async t => {
18881884
let expectedEntry
18891885
const expectedLogEntry = {
1890-
error: !satisfies(process.versions.node, '>=20.x')
1891-
? new SyntaxError('Unexpected token { in JSON at position 1')
1892-
: new SyntaxError(
1893-
"Expected property name or '}' in JSON at position 1"
1894-
),
1886+
error: new SyntaxError('Unexpected token { in JSON at position 1'),
18951887
message: 'Malformed log entry'
18961888
}
18971889
class LogMock extends BaseLogMock {
@@ -1908,7 +1900,8 @@ tap.test('CloudLogging#async', root => {
19081900
)
19091901

19101902
t.same(meta, expectedMeta)
1911-
t.same(log, expectedLogEntry)
1903+
t.same(log.message, 'Malformed log entry')
1904+
t.type(log.error, SyntaxError)
19121905

19131906
return (
19141907
(expectedEntry = Object.assign({}, meta, {
@@ -1943,7 +1936,7 @@ tap.test('CloudLogging#async', root => {
19431936
'@google-cloud/logging': { Logging: LoggingMock }
19441937
})
19451938

1946-
t.plan(3)
1939+
t.plan(4)
19471940

19481941
const instance = new CloudLogging(logName, defaultOptions)
19491942

0 commit comments

Comments
 (0)