-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathexec_test.go
More file actions
37 lines (30 loc) · 1.07 KB
/
Copy pathexec_test.go
File metadata and controls
37 lines (30 loc) · 1.07 KB
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
package exec
import (
"testing"
)
func TestChecker(t *testing.T) {
assert := func(ok bool, format string, args ...any) {
if !ok {
t.Errorf(format, args...)
}
}
command := "testdata/exec.sh"
// check non-zero exit code
{
testName := "Non-zero exit"
hc := Checker{Name: testName, Command: command, Arguments: []string{"1", testName}, Attempts: 2}
result, err := hc.Check()
assert(err == nil, "expected no error, got %v, %#v", err, result)
assert(result.Title == testName, "expected result.Title == %s, got '%s'", testName, result.Title)
assert(result.Down == true, "expected result.Down = true, got %v", result.Down)
}
// check zero exit code
{
testName := "Non-zero exit"
hc := Checker{Name: testName, Command: command, Arguments: []string{"0", testName}, Attempts: 2}
result, err := hc.Check()
assert(err == nil, "expected no error, got %v, %#v", err, result)
assert(result.Title == testName, "expected result.Title == %s, got '%s'", testName, result.Title)
assert(result.Down == false, "expected result.Down = false, got %v", result.Down)
}
}