-
Notifications
You must be signed in to change notification settings - Fork 0
/
vcsinfo_suite_test.go
50 lines (41 loc) · 936 Bytes
/
vcsinfo_suite_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
package vcsinfo_test
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestProbes(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "vcsinfo Suite")
}
func mkdir(pathParts ...string) string {
path := filepath.Join(pathParts...)
os.MkdirAll(path, os.ModePerm)
return path
}
func tmpdir() string {
dir, _ := ioutil.TempDir("", "vcsinfo")
return dir
}
func writeFile(dir string, file string, content string) {
ioutil.WriteFile(filepath.Join(dir, file), []byte(content), 0666)
}
func rm(dir string, file string) {
os.Remove(filepath.Join(dir, file))
}
func rmdir(dir string) {
os.RemoveAll(dir)
}
func run(dir string, command ...string) {
cmd := exec.Command(command[0], command[1:]...)
cmd.Dir = dir
out, err := cmd.CombinedOutput()
if err != nil {
Fail(fmt.Sprintf("Failed to execute %s %+v\n%s", command, err, out))
}
}