-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgetCredentialsForBash.test.js
63 lines (54 loc) · 1.47 KB
/
getCredentialsForBash.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
'use strict';
const concat = require('concat-stream');
const { PassThrough } = require('stream');
const getCredentialsForBash = require('./getCredentialsForBash');
test('will print to stderr the selected aws profile name', () => {
return new Promise((resolve, reject) => {
expect.assertions(1);
const stderr = new PassThrough();
const stdin = new PassThrough();
stderr.pipe(concat((output) => {
expect(output.toString('utf8')).toMatch('Using the "default" aws profile.');
resolve();
}));
setTimeout(() => {
stdin.write('hello\n');
}, 10);
return getCredentialsForBash({
argv: [],
env: {},
stderr,
stdin,
stdout: new PassThrough()
}).then(() => {
stderr.end();
}, () => {
stderr.end();
});
});
});
test('will print to stderr the selected aws profile name if passed profile name via cli', () => {
return new Promise((resolve, reject) => {
expect.assertions(1);
const stderr = new PassThrough();
const stdin = new PassThrough();
stderr.pipe(concat((output) => {
expect(output.toString('utf8')).toMatch('Using the "cliProfileName" aws profile.');
resolve();
}));
setTimeout(() => {
stdin.write('hello\n');
}, 10);
return getCredentialsForBash({
argv: ['cliProfileName'],
env: {},
stderr,
stdin,
stdout: new PassThrough()
}).then(() => {
stderr.end();
}, () => {
stderr.end();
});
});
});