-
Notifications
You must be signed in to change notification settings - Fork 158
/
command_test.go
44 lines (36 loc) · 1023 Bytes
/
command_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
package actionlint
import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"
)
func TestCommandMain(t *testing.T) {
var output bytes.Buffer
// Create command instance populating stdin/stdout/stderr
cmd := Command{
Stdin: os.Stdin,
Stdout: &output,
Stderr: &output,
}
// Run the command end-to-end. Note that given args should contain program name
workflow := filepath.Join("testdata", "examples", "main.yaml")
status := cmd.Main([]string{"actionlint", "-shellcheck=", "-pyflakes=", "-ignore", `label .+ is unknown\.`, workflow})
if status != 1 {
t.Fatal("exit status should be 1 but got", status)
}
out := output.String()
for _, s := range []string{
"main.yaml:3:5:",
"unexpected key \"branch\" for \"push\" section",
"^~~~~~~~~~~~~~~",
} {
if !strings.Contains(out, s) {
t.Errorf("output should contain %q: %q", s, out)
}
}
if strings.Contains(out, "[runner-label]") {
t.Errorf("runner-label rule should be ignored by -ignore but it is included in output: %q", out)
}
}