-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
docker.bats
88 lines (71 loc) · 2.07 KB
/
docker.bats
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bats
function dockerRun() {
docker run --rm -v "$(pwd)":/bot ${IMAGE_NAME:-'wechaty/wechaty:artifact'} $@
}
fixtures=tests/fixtures/docker
@test "should succ with a simple javascript" {
cd "$fixtures"
run dockerRun cjs/js-bot.js
[ "$status" -eq 0 ]
}
@test "should fail when javascript syntax error" {
cd "$fixtures"
run dockerRun syntax-error.js
[ "$status" -ne 0 ]
}
@test "should succ with javascript ESM import syntax" {
cd "$fixtures"
run dockerRun esm/es6-import.js
[ "$status" -eq 0 ] # should succ
}
@test "should fail with javascript es6 import when setting NODE_ENV=production" {
cd "$fixtures"
run dockerRun -e NODE_ENV=production es6-import.js
[ "$status" -ne 0 ] # should fail
}
@test "should succ with a simple typescript" {
cd "$fixtures"
run dockerRun esm/ts-bot.ts
[ "$status" -eq 0 ]
}
@test "should not fail with unmatch types in typescript (with `ts-node.transpileOnly=true`)" {
cd "$fixtures"
run dockerRun type-error.ts
[ "$status" -eq 0 ]
}
@test "should succ when using require with javascript" {
cd "$fixtures/with-package-json/"
run dockerRun with-require.cjs
[ "$status" -eq 0 ]
}
@test "should fail when require a not exist module in javascript" {
cd "$fixtures/with-package-json/"
run dockerRun with-require-error.js
[ "$status" -ne 0 ]
}
@test "should succ when using import in typescript" {
cd "$fixtures/with-package-json/"
run dockerRun with-import.ts
[ "$status" -eq 0 ]
}
@test "should fail when import a not exist module in typescript" {
cd "$fixtures/with-package-json/"
run dockerRun with-import-error.ts
[ "$status" -ne 0 ]
}
@test "should succ with arg: 'doctor' (which is the default by npm run)" {
run dockerRun doctor
[ "$status" -eq 0 ]
}
@test "should succ with arg: 'run doctor'" {
run dockerRun run doctor
[ "$status" -eq 0 ]
}
@test "should fail when run an unknown arg" {
run dockerRun run fdasfadsfasdfasdfasdfasd
[ "$status" -ne 0 ]
}
@test "should fail when passing an unknown arg directly" {
run dockerRun fdasfadsfasdfasdfasdfasd
[ "$status" -ne 0 ]
}