-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_test.go
42 lines (36 loc) · 904 Bytes
/
cli_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
package main
import (
"bytes"
"os"
"os/exec"
"testing"
assert "github.com/stretchr/testify/assert"
gl "github.com/tongson/gl"
)
func TestVersionString(t *testing.T) {
if os.Getenv("GOTEST") == "1" {
printVersion()
}
cmd := exec.Command(os.Args[0], "-test.run=TestVersionString")
cmd.Env = append(os.Environ(), "GOTEST=1")
var stdout bytes.Buffer
cmd.Stdout = &stdout
err := cmd.Run()
_, ok := err.(*exec.ExitError)
assert.Equal(t, false, ok)
expectedString := versionStringG + "\n"
assert.Equal(t, expectedString, stdout.String())
}
func TestLogCreation(t *testing.T) {
lf := "cli_test.json"
jl := jLog(lf)
jl.Info().Msg("test")
assert.Equal(t, true, gl.IsFile(lf))
os.Remove(lf)
}
func TestUnixSocket(t *testing.T) {
l := unixSocket("cli_test.socket")
assert.Equal(t, true, gl.IsFile("cli_test.socket"))
l.Close()
assert.Equal(t, false, gl.IsFile("cli_test.socket"))
}