-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
100 lines (74 loc) · 2.17 KB
/
main_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
// +build integration
package main
import (
"testing"
"github.com/fern4lvarez/apto/apto"
)
var (
msg = "%v. Expects %v, returns %v"
)
func TestInstall(t *testing.T) {
spec := "Should execute `apto install gnomine`"
command := []string{"apto", "install", "gnomine"}
if err := apto.Execute(command); err != nil {
t.Errorf(msg, spec, nil, err)
}
spec = "Should exit when install command has no packages"
command = []string{"apto", "install"}
if err := apto.Execute(command); err == nil {
t.Errorf(spec)
}
}
func TestUninstall(t *testing.T) {
spec := "Should execute `apto uninstall gnomine`"
command := []string{"apto", "uninstall", "gnomine"}
if err := apto.Execute(command); err != nil {
t.Errorf(msg, spec, nil, err)
}
spec = "Should execute `apto -f uninstall gnomine`"
command = []string{"apto", "-f", "uninstall", "gnomine"}
if err := apto.Execute(command); err != nil {
t.Errorf(spec)
}
spec = "Should execute `apto uninstall -f gnomine`"
command = []string{"apto", "uninstall", "-f", "gnomine"}
if err := apto.Execute(command); err != nil {
t.Errorf(spec)
}
spec = "Should exit when uninstall command has no packages"
command = []string{"apto", "uninstall"}
if err := apto.Execute(command); err == nil {
t.Errorf(spec)
}
}
func TestUpdate(t *testing.T) {
spec := "Should execute `apto update`"
command := []string{"apto", "update"}
if err := apto.Execute(command); err != nil {
t.Errorf(msg, spec, nil, err)
}
spec = "Should exit when update command has more parameters"
command = []string{"apto", "update", "foo"}
if err := apto.Execute(command); err == nil {
t.Errorf(spec)
}
}
func TestUpgrade(t *testing.T) {
spec := "Should execute `apto upgrade`"
command := []string{"apto", "upgrade"}
if err := apto.Execute(command); err != nil {
t.Errorf(msg, spec, nil, err)
}
spec = "Should exit when upgrade command has more parameters"
command = []string{"apto", "upgrade", "foo"}
if err := apto.Execute(command); err == nil {
t.Errorf(spec)
}
}
func TestFile(t *testing.T) {
spec := "Should execute `apto file`"
command := []string{"apto", "file"}
if err := apto.Execute(command); err != nil {
t.Errorf(msg, spec, nil, err)
}
}