Skip to content

Commit a1feddf

Browse files
committed
remove use of deprecated close in tests
1 parent 29fb286 commit a1feddf

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

plugins/node/instrumentation-typeorm/test/Connection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('Connection', () => {
6060
assert.strictEqual(attributes[ATTR_DB_NAMESPACE], options.database);
6161
assert.strictEqual(attributes[ATTR_DB_OPERATION_NAME], 'raw query');
6262
assert.strictEqual(attributes[ATTR_DB_QUERY_TEXT], query);
63-
await connection.close();
63+
await connection.destroy();
6464
});
6565
});
6666
});

plugins/node/instrumentation-typeorm/test/EntityManager.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('EntityManager', () => {
4949
it('save using connection.manager', async () => {
5050
const options = defaultOptions;
5151
const connection = await typeorm.createConnection(defaultOptions);
52-
const user = new User(1, 'aspecto', 'io');
52+
const user = new User(1, 'opentelemetry', 'io');
5353
await connection.manager.save(user);
5454
const typeOrmSpans = getTestSpans();
5555

@@ -64,14 +64,14 @@ describe('EntityManager', () => {
6464
attributes[ATTR_DB_QUERY_TEXT],
6565
JSON.stringify({ targetOrEntity: user })
6666
);
67-
await connection.close();
67+
await connection.destroy();
6868
});
6969

7070
it('save', async () => {
7171
const options = defaultOptions;
7272
const connection = await typeorm.createConnection(defaultOptions);
7373
const manager = connection.createEntityManager();
74-
const user = new User(1, 'aspecto', 'io');
74+
const user = new User(1, 'opentelemetry', 'io');
7575
await manager.save(user);
7676
const typeOrmSpans = getTestSpans();
7777

@@ -86,15 +86,15 @@ describe('EntityManager', () => {
8686
attributes[ATTR_DB_QUERY_TEXT],
8787
JSON.stringify({ targetOrEntity: user })
8888
);
89-
await connection.close();
89+
await connection.destroy();
9090
});
9191

9292
it('remove', async () => {
9393
const options = defaultOptions;
9494
const connection = await typeorm.createConnection(defaultOptions);
9595
const manager = connection.createEntityManager();
9696

97-
const user = new User(56, 'aspecto', 'io');
97+
const user = new User(56, 'opentelemetry', 'io');
9898
await manager.save(user);
9999
await manager.remove(user);
100100
const typeOrmSpans = getTestSpans();
@@ -109,17 +109,21 @@ describe('EntityManager', () => {
109109
assert.strictEqual(
110110
attributes[ATTR_DB_QUERY_TEXT],
111111
JSON.stringify({
112-
targetOrEntity: { id: 56, firstName: 'aspecto', lastName: 'io' },
112+
targetOrEntity: {
113+
id: 56,
114+
firstName: 'opentelemetry',
115+
lastName: 'io',
116+
},
113117
})
114118
);
115-
await connection.close();
119+
await connection.destroy();
116120
});
117121

118122
it('update', async () => {
119123
const options = defaultOptions;
120124
const connection = await typeorm.createConnection(defaultOptions);
121125
const manager = connection.createEntityManager();
122-
const user = new User(56, 'aspecto', 'io');
126+
const user = new User(56, 'opentelemetry', 'io');
123127
await manager.save(user);
124128
const partialEntity = { lastName: '.io' };
125129
await manager.update(User, 56, partialEntity);
@@ -136,7 +140,7 @@ describe('EntityManager', () => {
136140
attributes[ATTR_DB_QUERY_TEXT],
137141
JSON.stringify({ target: 'User', criteria: 56, partialEntity })
138142
);
139-
await connection.close();
143+
await connection.destroy();
140144
});
141145

142146
it('Sets failure status when function throws', async () => {
@@ -153,7 +157,7 @@ describe('EntityManager', () => {
153157
typeOrmSpans[0].status.message,
154158
'No metadata for "[object Object]" was found.'
155159
);
156-
await connection.close();
160+
await connection.destroy();
157161
});
158162
});
159163

@@ -174,7 +178,7 @@ describe('EntityManager', () => {
174178
const manager1 = sqlite1.createEntityManager();
175179
const manager2 = sqlite2.createEntityManager();
176180

177-
const user = new User(1, 'aspecto', 'io');
181+
const user = new User(1, 'opentelemetry', 'io');
178182
await manager1.save(user);
179183
await manager2.remove(user);
180184

@@ -216,8 +220,8 @@ describe('EntityManager', () => {
216220
sqlite2Span.attributes[ATTR_DB_COLLECTION_NAME],
217221
'user'
218222
);
219-
await sqlite1.close();
220-
await sqlite2.close();
223+
await sqlite1.destroy();
224+
await sqlite2.destroy();
221225
});
222226
});
223227
});

plugins/node/instrumentation-typeorm/test/QueryBuilder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ describe('QueryBuilder', () => {
7171
attributes[ATTR_DB_QUERY_TEXT],
7272
'SELECT "user"."id" AS "user_id", "user"."firstName" AS "user_firstName", "user"."lastName" AS "user_lastName" FROM "user" "user" WHERE "user"."id" = :userId'
7373
);
74-
await connection.close();
74+
await connection.destroy();
7575
});
7676
});

plugins/node/instrumentation-typeorm/test/config.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('TypeormInstrumentationConfig', () => {
5555
instrumentation.enable();
5656

5757
const connection = await typeorm.createConnection(defaultOptions);
58-
const user = new User(1, 'aspecto', 'io');
58+
const user = new User(1, 'opentelemetry', 'io');
5959
await connection.manager.save(user);
6060
const typeOrmSpans = getTestSpans();
6161
assert.strictEqual(typeOrmSpans.length, 1);
@@ -64,7 +64,7 @@ describe('TypeormInstrumentationConfig', () => {
6464
assert.strictEqual(attributes['test'], JSON.stringify(user));
6565
assert.strictEqual(attributes[ATTR_DB_OPERATION_NAME], 'save');
6666
assert.strictEqual(attributes[ATTR_DB_SYSTEM_NAME], defaultOptions.type);
67-
await connection.close();
67+
await connection.destroy();
6868
});
6969

7070
it('enableInternalInstrumentation:true', async () => {
@@ -97,7 +97,7 @@ describe('TypeormInstrumentationConfig', () => {
9797
'select'
9898
);
9999
assert.strictEqual(selectSpan?.attributes[ATTR_DB_COLLECTION_NAME], 'user');
100-
await connection.close();
100+
await connection.destroy();
101101
});
102102

103103
it('enableInternalInstrumentation:false', async () => {
@@ -113,7 +113,7 @@ describe('TypeormInstrumentationConfig', () => {
113113
assert.strictEqual(attributes[ATTR_DB_OPERATION_NAME], 'findAndCount');
114114
assert.strictEqual(attributes[ATTR_DB_SYSTEM_NAME], defaultOptions.type);
115115
assert.strictEqual(attributes[ATTR_DB_COLLECTION_NAME], 'user');
116-
await connection.close();
116+
await connection.destroy();
117117
});
118118

119119
it('enhancedDatabaseReporting:true', async () => {
@@ -150,6 +150,6 @@ describe('TypeormInstrumentationConfig', () => {
150150
attributes[ExtendedDatabaseAttribute.DB_STATEMENT_PARAMETERS],
151151
JSON.stringify({ userId: '1', firstName: 'bob', lastName: 'dow' })
152152
);
153-
await connection.close();
153+
await connection.destroy();
154154
});
155155
});

0 commit comments

Comments
 (0)