-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest.ts
executable file
·72 lines (62 loc) · 2 KB
/
test.ts
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
import {
assertEquals,
} from "https://deno.land/std/testing/asserts.ts";
import { exec, execSequence, IExecResponse, OutputMode } from "./mod.ts";
Deno.test({
name: "Testing Simple Commands",
async fn(): Promise<void> {
let response = await exec(
"echo Hello World",
{ output: OutputMode.None, verbose: true },
);
assertEquals(response.output, "");
assertEquals(response.status.code, 0);
response = await exec("echo Hello World");
assertEquals(response.output, "");
assertEquals(response.status.code, 0);
response = await exec(
"echo Hello World",
{ output: OutputMode.Capture, verbose: true },
);
assertEquals(response.output, "Hello World");
assertEquals(response.status.code, 0);
response = await exec(
"cat helloworld.txt",
{ output: OutputMode.Capture, verbose: true },
);
assertEquals(response.output, "Hello World");
assertEquals(response.status.code, 0);
response = await exec(
"echo Hello World",
{ output: OutputMode.Tee, verbose: true },
);
assertEquals(response.output, "Hello World");
assertEquals(response.status.code, 0);
response = await exec(
"cat helloworld.txt",
{ output: OutputMode.Tee, verbose: true },
);
assertEquals(response.output, "Hello World");
assertEquals(response.status.code, 0);
response = await exec(
"cat anonexistentfile.txt",
{ output: OutputMode.Capture, verbose: true },
);
assertEquals(response.output, "cat: anonexistentfile.txt: No such file or directory");
assertEquals(response.status.code, 1);
},
});
Deno.test({
name: "Testing Command Sequences",
async fn(): Promise<void> {
let response = await execSequence([
"echo Hello World",
"ls -l",
"cat helloworld.txt",
], { output: OutputMode.None, continueOnError: false, verbose: true });
assertEquals(response.length, 3);
response.forEach((r: IExecResponse) => {
assertEquals(r.status.code, 0);
});
},
});