-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_test.go
35 lines (29 loc) · 978 Bytes
/
cli_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
package main
import (
"bytes"
"fmt"
"strings"
"testing"
)
func TestRun_versionFlag(t *testing.T) {
outStream, errStream := new(bytes.Buffer), new(bytes.Buffer)
cli := &CLI{outStream: outStream, errStream: errStream}
args := strings.Split("./cvlin -version", " ")
status := cli.Run(args)
if status != ExitCodeOK {
t.Errorf("Unexpected Status Code: expected %d but got %d", ExitCodeOK, status)
}
expected := fmt.Sprintf("v%s", Version)
if !strings.Contains(outStream.String(), expected) {
t.Errorf("Unexpected output: expected %q but got %q", expected, outStream.String(),)
}
}
func TestRun_ruleFlag(t *testing.T) {
outStream, errStream := new(bytes.Buffer), new(bytes.Buffer)
cli := &CLI{outStream: outStream, errStream: errStream}
args := strings.Split("./cvlin --rule example/rule.toml example/subject.csv", " ")
status := cli.Run(args)
if status != ExitCodeOK {
t.Errorf("Unexpected Status Code: expected %d but got %d", ExitCodeOK, status)
}
}