Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Moved pkgVersion to collection-common to avoid a conflict with ESM tests #2438

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading