-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathECR.test.js
32 lines (27 loc) · 926 Bytes
/
ECR.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
const Test = require('thunk-test')
const assert = require('assert')
const ECR = require('./ECR')
const AwsCredentials = require('./internal/AwsCredentials')
const test = new Test('ECR', async function () {
const awsCreds = await AwsCredentials('default').catch(error => {
if (error.code == 'ENOENT') {
const accessKeyId = process.env.AWS_ACCESS_KEY_ID
const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY
if (accessKeyId == null || secretAccessKey == null) {
throw new Error('No AWS credential file or environment variables')
}
return { accessKeyId, secretAccessKey }
}
throw error
})
awsCreds.region = 'us-west-1'
const ecr = new ECR({
...awsCreds,
})
const { authorizationToken } = await ecr.getAuthorizationToken()
assert.equal(typeof authorizationToken, 'string')
}).case()
if (process.argv[1] == __filename) {
test()
}
module.exports = test