Skip to content

Commit 3eb0d8f

Browse files
committed
Move obtainTestInstance into the before block for
backups
1 parent 99cdfbd commit 3eb0d8f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

samples/test/backups.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ describe('backups', async () => {
2525
const TABLE_ID = generateId();
2626
const BACKUP_ID = generateId();
2727

28-
const instance = await obtainTestInstance();
29-
30-
const INSTANCE_ID = instance.id;
31-
const CLUSTER_ID = instance.id; // The test function uses the same name.
32-
33-
const table = instance.table(TABLE_ID);
34-
const cluster = instance.cluster(INSTANCE_ID);
35-
const backup = cluster.backup(BACKUP_ID);
28+
let instance;
29+
let INSTANCE_ID;
30+
let CLUSTER_ID;
31+
let table;
32+
let cluster;
33+
let backup;
3634

3735
async function createTestBackup(backupId) {
3836
const [backup, operation] = await cluster.createBackup(backupId, {
@@ -44,6 +42,15 @@ describe('backups', async () => {
4442
}
4543

4644
before(async () => {
45+
instance = await obtainTestInstance();
46+
47+
INSTANCE_ID = instance.id;
48+
CLUSTER_ID = instance.id; // The test function uses the same name.
49+
50+
table = instance.table(TABLE_ID);
51+
cluster = instance.cluster(INSTANCE_ID);
52+
backup = cluster.backup(BACKUP_ID);
53+
4754
await table.create();
4855
await table.createFamily('follows');
4956
await table.insert([

samples/test/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ async function getStaleInstances() {
5050
* the result.
5151
*/
5252
async function obtainTestInstance() {
53+
// Note: Do not use this function if it is only inside a describe block.
5354
if (!obtainPromise) {
5455
obtainPromise = createTestInstance();
5556
}

0 commit comments

Comments
 (0)