This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelp_test.go
105 lines (89 loc) · 3.36 KB
/
help_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package main_test
import (
"testing"
"github.com/stealthrocket/timecraft/internal/assert"
)
var help = tests{
"calling help with an unknown command causes an error": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "whatever")
assert.Equal(t, exitCode, 2)
assert.Equal(t, stdout, "")
assert.Equal(t, stderr, "timecraft help whatever: unknown command\n")
},
"passing an unsupported flag to the command causes an error": func(t *testing.T) {
_, _, exitCode := timecraft(t, "help", "-_")
assert.Equal(t, exitCode, 2)
},
"show the help command help with the short option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "-h")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft <command> ")
assert.Equal(t, stderr, "")
},
"show the help command help with the long option": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "--help")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft <command> ")
assert.Equal(t, stderr, "")
},
"show the help command help after a command name": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "get", "--help")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft <command> ")
assert.Equal(t, stderr, "")
},
"timecraft help config": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "config")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft config ")
assert.Equal(t, stderr, "")
},
"timecraft help describe": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "describe")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft describe ")
assert.Equal(t, stderr, "")
},
"timecraft help export": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "export")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft export ")
assert.Equal(t, stderr, "")
},
"timecraft help get": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "get")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft get ")
assert.Equal(t, stderr, "")
},
"timecraft help help": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "help")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft <command> ")
assert.Equal(t, stderr, "")
},
"timecraft help profile": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "profile")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft profile ")
assert.Equal(t, stderr, "")
},
"timecraft help run": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "run")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft run ")
assert.Equal(t, stderr, "")
},
"timecraft help replay": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "replay")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft replay ")
assert.Equal(t, stderr, "")
},
"timecraft help version": func(t *testing.T) {
stdout, stderr, exitCode := timecraft(t, "help", "version")
assert.Equal(t, exitCode, 0)
assert.HasPrefix(t, stdout, "Usage:\ttimecraft version\n")
assert.Equal(t, stderr, "")
},
}