Skip to content

Commit 7b041ff

Browse files
committed
added simple test
1 parent 2ecc4b3 commit 7b041ff

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/cp_test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,35 @@ describe('Cp', () => {
3838
await cp.cpFromPod(namespace, pod, container, srcPath, tgtPath);
3939
verify(fakeWebSocket.connect(`${path}?${queryStr}`, null, anyFunction())).called();
4040
});
41+
42+
it('should run create tar command to a url with cwd', async () => {
43+
const kc = new KubeConfig();
44+
const fakeWebSocket: WebSocketInterface = mock(WebSocketHandler);
45+
const exec = new Exec(kc, instance(fakeWebSocket));
46+
const cp = new Cp(kc, exec);
47+
48+
const namespace = 'somenamespace';
49+
const pod = 'somepod';
50+
const container = 'container';
51+
const srcPath = '/';
52+
const tgtPath = '/';
53+
const cwd = '/abc';
54+
const cmdArray = ['tar', 'zcf', '-', '-C', cwd, srcPath];
55+
const path = `/api/v1/namespaces/${namespace}/pods/${pod}/exec`;
56+
57+
const query = {
58+
stdout: true,
59+
stderr: true,
60+
stdin: false,
61+
tty: false,
62+
command: cmdArray,
63+
container,
64+
};
65+
const queryStr = querystring.stringify(query);
66+
67+
await cp.cpFromPod(namespace, pod, container, srcPath, tgtPath, cwd);
68+
verify(fakeWebSocket.connect(`${path}?${queryStr}`, null, anyFunction())).called();
69+
});
4170
});
4271

4372
describe('cpToPod', () => {

0 commit comments

Comments
 (0)