-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.go
90 lines (80 loc) · 1.6 KB
/
run_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
package main
import (
"io/ioutil"
"os"
"path"
"strings"
"testing"
)
func TestRun(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Error(err)
}
tmp, err := ioutil.TempDir(wd, "helm-run")
if err != nil {
t.Error(err)
}
defer os.RemoveAll(tmp)
runCmd := runCmd{
dos2unix: true,
command: path.Join(strings.Replace(tmp, wd+"/", "", -1), "hello"),
args: []string{"Matt"},
pwd: wd,
local: true,
}
ioutil.WriteFile(path.Join(tmp, "hello"), []byte(`
echo "hello $@"
`), defaultDirectoryPermission)
err = runCmd.run()
if err != nil {
t.Error(err)
}
}
func TestRun_Make(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Error(err)
}
tmp, err := ioutil.TempDir(wd, "helm-run")
if err != nil {
t.Error(err)
}
defer os.RemoveAll(tmp)
runCmd := runCmd{
dos2unix: true,
command: path.Join(strings.Replace(tmp, wd+"/", "", -1), "hello"),
args: []string{"NAME=Matt"},
pwd: wd,
local: true,
make: true,
}
ioutil.WriteFile(path.Join(tmp, "hello"), []byte(`
NAME := anonymous
all: hello my_name
hello:
echo "hello"
my_name:
echo "$(NAME)"
`), defaultDirectoryPermission)
err = runCmd.run()
if err != nil {
t.Error(err)
}
}
func TestGetCommandContents(t *testing.T) {
//runCmd := runCmd{
// command: "package",
// commandOwner: commandOwner,
// commandRepo: commandRepo,
// commandPathBase: commandPathBase,
//}
//c, err := runCmd.getCommandContents()
//if err != nil {
// t.Error(err)
//}
//fmt.Println(c)
//if !strings.Contains(c, "#!/usr/bin/env bash") {
// t.Error("package should be a bash command")
//}
}