-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpicel_test.go
53 lines (43 loc) · 1.06 KB
/
picel_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
package main
import (
"bytes"
"log"
"testing"
"github.com/henvic/picel/logger"
)
type ExistsDependencyProvider struct {
cmd string
find bool
}
func TestVersion(t *testing.T) {
flagVersion = true
main()
}
func TestExistsDependency(t *testing.T) {
for _, c := range existsDependencyCases {
exists := existsDependency(c.cmd)
if exists != c.find {
t.Errorf("existsDependency(%v) should return %v", c.cmd, c.find)
}
}
}
type CheckMissingDependenciesProvider struct {
cmds []string
allExists bool
}
func TestCheckMissingDependencies(t *testing.T) {
for _, c := range CheckMissingDependencies {
var StdoutMock bytes.Buffer
var StderrMock bytes.Buffer
defaultStdout := logger.Stdout
defaultStderr := logger.Stderr
logger.Stdout = log.New(&StdoutMock, "", log.LstdFlags)
logger.Stderr = log.New(&StderrMock, "", log.LstdFlags)
checkMissingDependencies(c.cmds...)
logger.Stdout = defaultStdout
logger.Stderr = defaultStderr
if StdoutMock.String() != "" {
t.Errorf("checkMissingDependencies(%v) stdout should be empty", c.cmds)
}
}
}