-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.test.js
102 lines (83 loc) · 2.68 KB
/
mod.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import { assert, assertEquals, validateFactorySchema } from './dev_deps.js'
import createFactory from './mod.js'
const { test } = Deno
// TODO: probably a better way to do this
console.log = () => {}
test('mod', async (t) => {
await t.step('should be a valid schema', () => {
const factory = createFactory('foo')
assert(validateFactorySchema(factory))
})
await t.step('load', async (t) => {
await t.step('load - should return the object', () => {
const factory = createFactory('foo')
const res = factory.load()
assert(res.name)
assert(res.factory)
assert(res.aws)
assert(res.aws.s3)
assert(res.aws.sqs)
})
await t.step('load - should use provided options', async () => {
const res = createFactory('foo', {
sleep: 1000,
concurrency: 15,
awsAccessKeyId: 'foo',
awsSecretKey: 'bar',
region: 'fizz',
}).load()
await res.factory.ensureCredentialsAvailable()
assert(true)
assertEquals(res.sleep, 1000)
assertEquals(res.concurrency, 15)
})
await t.step('load - should use options passed to load', async () => {
const res = createFactory('foo').load({
sleep: 1000,
awsAccessKeyId: 'foo',
awsSecretKey: 'bar',
region: 'fizz',
})
await res.factory.ensureCredentialsAvailable()
assert(true)
assertEquals(res.sleep, 1000)
})
await t.step(
'load - should merge options, preferring those passed to adapter',
async () => {
const res = createFactory('foo', {
sleep: 1000,
awsAccessKeyId: 'better-id',
})
.load({
sleep: 2000,
awsAccessKeyId: 'foo',
awsSecretKey: 'bar',
region: 'fizz',
})
await res.factory.ensureCredentialsAvailable()
assertEquals(res.name, 'foo')
assertEquals(res.awsAccessKeyId, 'better-id')
assertEquals(res.sleep, 1000)
assertEquals(res.awsSecretKey, 'bar')
assertEquals(res.region, 'fizz')
},
)
await t.step('load - should default the region to us-east-1', async () => {
const res = createFactory('foo').load({
awsAccessKeyId: 'foo',
awsSecretKey: 'bar',
})
await res.factory.ensureCredentialsAvailable()
assertEquals(res.region, 'us-east-1')
})
await t.step('load - should default the sleep to 10000', () => {
const res = createFactory('foo').load()
assertEquals(res.sleep, 10000)
})
await t.step('load - should default the concurrency to 20', () => {
const res = createFactory('foo').load()
assertEquals(res.concurrency, 20)
})
})
})