Skip to content

Commit

Permalink
tests: fix assertions on cassandra-driver tests (#3652)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna authored Sep 29, 2023
1 parent 97b8803 commit dada020
Showing 1 changed file with 55 additions and 51 deletions.
106 changes: 55 additions & 51 deletions test/instrumentation/modules/cassandra-driver/cassandra-driver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CASSANDRA_VERSION = safeGetPackageVersion('cassandra-driver');
const TEST_KEYSPACE = 'mykeyspace';
const TEST_TABLE = 'myTable';
const TEST_DATACENTER = 'datacenter1';
const TEST_USE_PROMISES = String(semver.satisfies(CASSANDRA_VERSION, '>=3.2'));
const TEST_USE_PROMISES = semver.satisfies(CASSANDRA_VERSION, '>=3.2');

const testFixtures = [
{
Expand All @@ -37,7 +37,7 @@ const testFixtures = [
TEST_KEYSPACE,
TEST_TABLE,
TEST_DATACENTER,
TEST_USE_PROMISES,
TEST_USE_PROMISES: String(TEST_USE_PROMISES),
},
versionRanges: {
// [email protected] introduced a change that requires nodejs v16.9
Expand Down Expand Up @@ -240,32 +240,34 @@ const testFixtures = [
'execute with callback produced expected span',
);

t.deepEqual(
spans.shift(),
{
name: 'SELECT FROM system.local',
type: 'db',
subtype: 'cassandra',
action: 'query',
context: {
db: {
type: 'cassandra',
statement: 'SELECT key FROM system.local',
instance: TEST_KEYSPACE,
},
service: { target: { type: 'cassandra', name: TEST_KEYSPACE } },
destination: {
service: {
type: '',
name: '',
resource: `cassandra/${TEST_KEYSPACE}`,
if (TEST_USE_PROMISES) {
t.deepEqual(
spans.shift(),
{
name: 'SELECT FROM system.local',
type: 'db',
subtype: 'cassandra',
action: 'query',
context: {
db: {
type: 'cassandra',
statement: 'SELECT key FROM system.local',
instance: TEST_KEYSPACE,
},
service: { target: { type: 'cassandra', name: TEST_KEYSPACE } },
destination: {
service: {
type: '',
name: '',
resource: `cassandra/${TEST_KEYSPACE}`,
},
},
},
outcome: 'success',
},
outcome: 'success',
},
'execute with promise produced expected span',
);
'execute with promise produced expected span',
);
}

t.deepEqual(
spans.shift(),
Expand Down Expand Up @@ -297,35 +299,37 @@ const testFixtures = [
'batch with callback produced expected span',
);

t.deepEqual(
spans.shift(),
{
name: 'Cassandra: Batch query',
type: 'db',
subtype: 'cassandra',
action: 'query',
context: {
db: {
type: 'cassandra',
statement: [
`INSERT INTO ${TEST_TABLE} (id, text) VALUES (uuid(), ?)`,
`INSERT INTO ${TEST_TABLE} (id, text) VALUES (uuid(), ?)`,
].join(';\n'),
instance: TEST_KEYSPACE,
},
service: { target: { type: 'cassandra', name: TEST_KEYSPACE } },
destination: {
service: {
type: '',
name: '',
resource: `cassandra/${TEST_KEYSPACE}`,
if (TEST_USE_PROMISES) {
t.deepEqual(
spans.shift(),
{
name: 'Cassandra: Batch query',
type: 'db',
subtype: 'cassandra',
action: 'query',
context: {
db: {
type: 'cassandra',
statement: [
`INSERT INTO ${TEST_TABLE} (id, text) VALUES (uuid(), ?)`,
`INSERT INTO ${TEST_TABLE} (id, text) VALUES (uuid(), ?)`,
].join(';\n'),
instance: TEST_KEYSPACE,
},
service: { target: { type: 'cassandra', name: TEST_KEYSPACE } },
destination: {
service: {
type: '',
name: '',
resource: `cassandra/${TEST_KEYSPACE}`,
},
},
},
outcome: 'success',
},
outcome: 'success',
},
'batch with promise produced expected span',
);
'batch with promise produced expected span',
);
}

t.deepEqual(
spans.shift(),
Expand Down

0 comments on commit dada020

Please sign in to comment.