Skip to content

Commit

Permalink
test: fix messages checking (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
metcoder95 authored Apr 1, 2024
1 parent 95f9dd0 commit c1c4285
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions test/unit/cloud_logging.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const tap = require('tap')
const { satisfies } = require('semver')

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

Expand Down Expand Up @@ -973,11 +972,7 @@ tap.test('CloudLogging#sync', root => {
async t => {
let expectedEntry
const expectedLogEntry = {
error: !satisfies(process.versions.node, '>=20.x')
? new SyntaxError('Unexpected token { in JSON at position 1')
: new SyntaxError(
"Expected property name or '}' in JSON at position 1"
),
error: new SyntaxError('Unexpected token { in JSON at position 1'),
message: 'Malformed log entry'
}
class LogMock extends BaseLogMock {
Expand All @@ -994,7 +989,8 @@ tap.test('CloudLogging#sync', root => {
)

t.same(meta, expectedMeta)
t.same(log, expectedLogEntry)
t.same(log.message, 'Malformed log entry')
t.type(log.error, SyntaxError)

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

t.plan(3)
t.plan(4)

const instance = new CloudLogging(logName, defaultOptions)

Expand Down Expand Up @@ -1887,11 +1883,7 @@ tap.test('CloudLogging#async', root => {
async t => {
let expectedEntry
const expectedLogEntry = {
error: !satisfies(process.versions.node, '>=20.x')
? new SyntaxError('Unexpected token { in JSON at position 1')
: new SyntaxError(
"Expected property name or '}' in JSON at position 1"
),
error: new SyntaxError('Unexpected token { in JSON at position 1'),
message: 'Malformed log entry'
}
class LogMock extends BaseLogMock {
Expand All @@ -1908,7 +1900,8 @@ tap.test('CloudLogging#async', root => {
)

t.same(meta, expectedMeta)
t.same(log, expectedLogEntry)
t.same(log.message, 'Malformed log entry')
t.type(log.error, SyntaxError)

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

t.plan(3)
t.plan(4)

const instance = new CloudLogging(logName, defaultOptions)

Expand Down

0 comments on commit c1c4285

Please sign in to comment.