Add some tests
This commit is contained in:
parent
3dca802a22
commit
f61d43d2a5
|
@ -1,8 +1,11 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -17,11 +20,6 @@ func TestFileExistNot(t *testing.T) {
|
|||
assert.True(t, !FileExists("Utils2.go"))
|
||||
}
|
||||
|
||||
func TestGlobalConfigurationDirectory(t *testing.T) {
|
||||
appFolder := GetGlobalConfigurationDirectory("myapp")
|
||||
assert.NotEmpty(t, appFolder)
|
||||
}
|
||||
|
||||
func TestJoiningSlash1(t *testing.T) {
|
||||
actual := JoiningSlash("http://my.tld/docs/", "bla/", "blub/")
|
||||
expected := "http://my.tld/docs/bla/blub/"
|
||||
|
@ -66,3 +64,27 @@ func TestIsSuperUser(t *testing.T) {
|
|||
assert.NotNil(t, cuser)
|
||||
assert.True(t, IsSuperUser())
|
||||
}
|
||||
|
||||
func TestGlobalConfigurationDirectoryWindows(t *testing.T) {
|
||||
if runtime.GOOS != "windows" {
|
||||
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS))
|
||||
}
|
||||
appFolder := GetGlobalConfigurationDirectory("myapp")
|
||||
assert.Equal(t, filepath.Join(os.Getenv("APPDATA"), "myapp"), appFolder)
|
||||
}
|
||||
|
||||
func TestGlobalConfigurationDirectoryLinux(t *testing.T) {
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS))
|
||||
}
|
||||
appFolder := GetGlobalConfigurationDirectory("myapp")
|
||||
assert.Equal(t, "/etc/myapp", appFolder)
|
||||
}
|
||||
|
||||
func TestGlobalConfigurationDirectoryMacOS(t *testing.T) {
|
||||
if runtime.GOOS != "darwin" {
|
||||
t.Skip(fmt.Sprintf("Skipping on OS %s", runtime.GOOS))
|
||||
}
|
||||
appFolder := GetGlobalConfigurationDirectory("myapp")
|
||||
assert.Equal(t, "/etc/myapp", appFolder)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue