-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (29 loc) · 1.11 KB
/
index.js
File metadata and controls
35 lines (29 loc) · 1.11 KB
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
import test from 'ava'
import td from '../helpers/testdouble'
const pkg = {
name: 'foo',
shep: {
region: 'us-east-1'
}
}
const env = 'development'
const functionName = 'bar'
const callback = td.function('callback')
const getLogResponse = {
events: [],
nextLogCall: callback
}
const load = td.replace('../../src/util/load')
td.when(load.pkg()).thenResolve(pkg)
td.when(load.lambdaConfig(functionName, env)).thenResolve({ FunctionName: functionName })
const cloudwatchLogs = td.replace('../../src/util/aws/cloudwatch-logs')
td.when(cloudwatchLogs.getLogGroup(td.matchers.contains({ FunctionName: functionName }))).thenResolve('/aws/log/group')
const lambda = td.replace('../../src/util/aws/lambda')
td.when(lambda.getAliasVersion(td.matchers.contains({ aliasName: env }))).thenResolve('1')
const getLogs = td.replace('../../src/util/get-logs')
td.when(getLogs(td.matchers.isA(Object))).thenResolve(getLogResponse)
test('Continues loop', async (t) => {
const shep = require('../../src/index')
await t.throws(shep.logs({ env, name: functionName, stream: true }))
td.verify(callback(td.matchers.isA(Number)))
})