-
Notifications
You must be signed in to change notification settings - Fork 3
/
dependencies_test.go
55 lines (40 loc) · 1.17 KB
/
dependencies_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
package goclitools
import (
"fmt"
"testing"
)
func TestDependencyCheck(t *testing.T) {
dep := Dependency{CheckCmd: "which ls", Name: "ls"}
res, err := dep.Check()
if err != nil {
t.Fatalf("expected nil error, received: %s", err.Error())
}
if !res {
t.Fatal("expected true result")
}
}
func TestInvalidDependencyCheck(t *testing.T) {
dep := Dependency{CheckCmd: "which blah2", Name: "blah2"}
res, err := dep.Check()
if err != nil {
t.Fatalf("expected nil error, received: %s", err.Error())
}
if res {
t.Fatal("expected false result")
}
}
func TestDependencyInstallation(t *testing.T) {
dep := Dependency{CheckCmd: "which blah", Name: "blah", InstallScripts: []DependencyScript{
DependencyScriptString{Fn: "ln -s /usr/local/bin/go /usr/local/bin/blah"},
}, UninstallScripts: []DependencyScript{
DependencyScriptString{Fn: "rm /usr/local/bin/blah"},
}}
if err := dep.Install(); err != nil {
fmt.Println(nil, err, err != nil, err == nil)
t.Fatalf("expected nil error, received: %s", err.Error())
}
if err := dep.Uninstall(); err != nil {
fmt.Println(err, err != nil, err == nil)
t.Fatalf("expected nil error, received: %s", err.Error())
}
}