forked from wagoodman/bashful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
55 lines (48 loc) · 1.27 KB
/
main_test.go
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
package main
import (
"strconv"
"testing"
)
func TestTaskErrorPolicy(t *testing.T) {
var simpleYamlStr string
var failedTasks []*Task
simpleYamlStr = `
tasks:
- cmd: false
ignore-failure: true
`
failedTasks = run([]byte(simpleYamlStr), map[string]string{})
if len(failedTasks) > 0 {
t.Error("TestTaskErrorPolicy: ignore-failure: Expected no tasks to fail, got " + strconv.Itoa(len(failedTasks)))
}
simpleYamlStr = `
tasks:
- cmd: false
`
failedTasks = run([]byte(simpleYamlStr), map[string]string{})
if len(failedTasks) != 1 {
t.Error("TestTaskErrorPolicy: ack failure: Expected exactly 1 task to fail, got " + strconv.Itoa(len(failedTasks)))
}
simpleYamlStr = `
config:
stop-on-failure: true
tasks:
- cmd: false
- cmd: false
`
failedTasks = run([]byte(simpleYamlStr), map[string]string{})
if len(failedTasks) != 1 {
t.Error("TestTaskErrorPolicy: stop on failure: Expected exactly 1 task to fail, got " + strconv.Itoa(len(failedTasks)))
}
simpleYamlStr = `
config:
stop-on-failure: false
tasks:
- cmd: false
- cmd: false
`
failedTasks = run([]byte(simpleYamlStr), map[string]string{})
if len(failedTasks) != 2 {
t.Error("TestTaskErrorPolicy: do not stop on failure: Expected exactly 2 task to fail, got " + strconv.Itoa(len(failedTasks)))
}
}