Skip to content
This repository was archived by the owner on Oct 1, 2021. It is now read-only.

Commit d3c0056

Browse files
authored
fix: use new s3 instance for every test (#124)
Fix race condition in tests where repo keys hang around.
1 parent 76686e6 commit d3c0056

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

test/browser.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ const { ShardingDatastore, shard: { NextToLast } } = require('datastore-core')
77
const BlockstoreDatastoreAdapter = require('blockstore-datastore-adapter')
88
const mockS3 = require('./fixtures/mock-s3')
99
const S3 = require('aws-sdk').S3
10-
const s3Instance = new S3({
11-
params: {
12-
Bucket: 'test'
13-
}
14-
})
15-
mockS3(s3Instance)
1610
const { createRepo } = require('./fixtures/repo')
1711

1812
/**
@@ -75,6 +69,13 @@ const CONFIGURATIONS = [{
7569
name: 'with s3',
7670
cleanup: () => {},
7771
createBackends: (prefix) => {
72+
const s3Instance = new S3({
73+
params: {
74+
Bucket: 'test'
75+
}
76+
})
77+
mockS3(s3Instance)
78+
7879
return {
7980
root: new DatastoreS3(prefix, {
8081
s3: s3Instance,

test/node.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ const { ShardingDatastore, shard: { NextToLast } } = require('datastore-core')
1010
const BlockstoreDatastoreAdapter = require('blockstore-datastore-adapter')
1111
const mockS3 = require('./fixtures/mock-s3')
1212
const S3 = require('aws-sdk').S3
13-
const s3Instance = new S3({
14-
params: {
15-
Bucket: 'test'
16-
}
17-
})
18-
mockS3(s3Instance)
1913
const { createRepo } = require('./fixtures/repo')
2014

2115
function cleanup (dir) {
@@ -64,6 +58,13 @@ const CONFIGURATIONS = [{
6458
name: 'with s3',
6559
cleanup: () => {},
6660
createBackends: (prefix) => {
61+
const s3Instance = new S3({
62+
params: {
63+
Bucket: 'test'
64+
}
65+
})
66+
mockS3(s3Instance)
67+
6768
return {
6869
root: new DatastoreS3(prefix, {
6970
s3: s3Instance,

0 commit comments

Comments
 (0)