utils tests

This commit is contained in:
alessio 2017-08-15 02:05:42 +02:00
parent a06563d4c9
commit d36d51257e
1 changed files with 20 additions and 0 deletions

View File

@ -3,6 +3,8 @@ package watcher
import ( import (
"flag" "flag"
"gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
"os"
"path/filepath"
"testing" "testing"
) )
@ -37,3 +39,21 @@ func TestDuplicates(t *testing.T) {
} }
} }
func TestInArray(t *testing.T) {
arr := []string{"a", "b", "c"}
if !inArray(arr[0], arr) {
t.Fatal("Unexpected", arr[0], "should be in", arr)
}
if inArray("d", arr) {
t.Fatal("Unexpected", "d", "shouldn't be in", arr)
}
}
func TestGetEnvPath(t *testing.T) {
expected := filepath.SplitList(os.Getenv("GOPATH"))[0]
result := getEnvPath("GOPATH")
if expected != result {
t.Fatal("Expected", expected, "instead", result)
}
}