Skip to content

Commit

Permalink
test: Moved pkgVersion to collection-common to avoid a conflict with …
Browse files Browse the repository at this point in the history
…ESM tests
  • Loading branch information
bizob2828 committed Aug 2, 2024
1 parent 578aead commit e885313
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions test/versioned/mongodb/collection-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const common = require('./common')
const tap = require('tap')
const helper = require('../../lib/agent_helper')
const mongoPackage = require('mongodb/package.json')

let METRIC_HOST_NAME = null
let METRIC_HOST_PORT = null
Expand All @@ -17,6 +18,7 @@ exports.close = common.close
exports.test = collectionTest
exports.dropTestCollections = dropTestCollections
exports.populate = populate
exports.pkgVersion = mongoPackage.version

const { COLLECTIONS } = common

Expand Down
6 changes: 3 additions & 3 deletions test/versioned/mongodb/collection-misc.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const common = require('./collection-common')
const semver = require('semver')
const { pkgVersion, STATEMENT_PREFIX, COLLECTIONS, DB_NAME } = require('./common')
const { STATEMENT_PREFIX, COLLECTIONS, DB_NAME } = require('./common')

function verifyAggregateData(t, data) {
t.equal(data.length, 3, 'should have expected amount of results')
Expand Down Expand Up @@ -87,7 +87,7 @@ common.test('rename', async function renameTest(t, collection, verify) {
verify(null, [`${STATEMENT_PREFIX}/rename`], ['rename'], { strict: false })
})

if (semver.satisfies(pkgVersion, '<6.0.0')) {
if (semver.satisfies(common.pkgVersion, '<6.0.0')) {
common.test('stats', async function statsTest(t, collection, verify) {
const data = await collection.stats({ i: 5 })
t.equal(data.ns, `${DB_NAME}.${COLLECTIONS.collection1}`)
Expand All @@ -98,7 +98,7 @@ if (semver.satisfies(pkgVersion, '<6.0.0')) {
})
}

if (semver.satisfies(pkgVersion, '<5.0.0')) {
if (semver.satisfies(common.pkgVersion, '<5.0.0')) {
common.test('mapReduce', async function mapReduceTest(t, collection, verify) {
const data = await collection.mapReduce(map, reduce, { out: { inline: 1 } })

Expand Down
4 changes: 2 additions & 2 deletions test/versioned/mongodb/collection-update.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

const common = require('./collection-common')
const semver = require('semver')
const { pkgVersion, STATEMENT_PREFIX } = require('./common')
const { STATEMENT_PREFIX } = require('./common')

/**
* The response from the methods in this file differ between versions
Expand Down Expand Up @@ -132,7 +132,7 @@ common.test('updateOne', async function updateOneTest(t, collection, verify) {
verify(null, [`${STATEMENT_PREFIX}/updateOne`], ['updateOne'], { strict: false })
})

if (semver.satisfies(pkgVersion, '<5.0.0')) {
if (semver.satisfies(common.pkgVersion, '<5.0.0')) {
common.test('insert', async function insertTest(t, collection, verify) {
const data = await collection.insert({ foo: 'bar' })
assertExpectedResult({
Expand Down
2 changes: 0 additions & 2 deletions test/versioned/mongodb/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

'use strict'

const mongoPackage = require('mongodb/package.json')
const params = require('../../lib/params')
const urltils = require('../../../lib/util/urltils')

Expand All @@ -26,7 +25,6 @@ exports.TRANSACTION_NAME = TRANSACTION_NAME
exports.DB_NAME = DB_NAME
exports.COLLECTIONS = COLLECTIONS
exports.STATEMENT_PREFIX = STATEMENT_PREFIX
exports.pkgVersion = mongoPackage.version

exports.connect = connect
exports.close = close
Expand Down

0 comments on commit e885313

Please sign in to comment.