-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
61 lines (54 loc) · 1.38 KB
/
main_test.go
File metadata and controls
61 lines (54 loc) · 1.38 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/timandy/routinex/tools/consts"
"github.com/timandy/routinex/tools/exec"
"github.com/timandy/routinex/tools/file"
)
var goToolDir = exec.RunCmdOutput([]string{"go", "env", "GOTOOLDIR"})
func TestHelp(t *testing.T) {
tracker := file.NewFileTracker(os.Stderr)
tracker.Begin()
defer tracker.End()
//
args := []string{"routinex", "-h", "/demo", "-p", "ttt", "go", "version"}
os.Args = args
main()
//
output := tracker.Value()
assert.Contains(t, output, "Usage: routinex")
}
func TestOtherCmd(t *testing.T) {
tracker := file.NewFileTracker(os.Stdout)
tracker.Begin()
defer tracker.End()
//
args := []string{"routinex", "-p", "/demo", "-p", "ttt", "git", "version"}
os.Args = args
main()
//
output := tracker.Value()
assert.Contains(t, output, "git version")
}
func TestOtherCmdHelp(t *testing.T) {
tracker := file.NewFileTracker(os.Stdout)
tracker.Begin()
defer tracker.End()
//
args := []string{"routinex", "-p", "/demo", "-p", "ttt", "git", "-h"}
os.Args = args
main()
//
output := tracker.Value()
assert.Contains(t, output, "usage: git")
}
func TestCompileCmdHelp(t *testing.T) {
compilePath := filepath.Join(goToolDir, consts.CompileName)
args := []string{"routinex", "-p", "/demo", "-p", "ttt", compilePath, "-h"}
os.Args = args
// expect exit 2
// main()
}