-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_test.go
53 lines (42 loc) · 1.33 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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("./cws-clocking-cli -version", " ")
version = "1.2.3"
status := cli.Run(args)
if status != ExitCodeOK {
t.Errorf("expected %d to eq %d", status, ExitCodeOK)
}
expected := fmt.Sprintf("cws-clocking-cli version %s", version)
if !strings.Contains(errStream.String(), expected) {
t.Errorf("expected %q to eq %q", errStream.String(), expected)
}
}
func TestRun_yesFlag(t *testing.T) {
outStream, errStream := new(bytes.Buffer), new(bytes.Buffer)
cli := &CLI{outStream: outStream, errStream: errStream}
args := strings.Split("./cws-clocking-cli -yes", " ")
status := cli.Run(args)
_ = status
}
func TestRun_outFlag(t *testing.T) {
outStream, errStream := new(bytes.Buffer), new(bytes.Buffer)
cli := &CLI{outStream: outStream, errStream: errStream}
args := strings.Split("./cws-clocking-cli -out", " ")
status := cli.Run(args)
_ = status
}
func TestRun_statusFlag(t *testing.T) {
outStream, errStream := new(bytes.Buffer), new(bytes.Buffer)
cli := &CLI{outStream: outStream, errStream: errStream}
args := strings.Split("./cws-clocking-cli -status", " ")
status := cli.Run(args)
_ = status
}