Skip to content

Commit

Permalink
Added Windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Jan 22, 2018
1 parent 8e9edda commit bb85ba7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
File renamed without changes.
56 changes: 56 additions & 0 deletions paths_windows_test.go
@@ -0,0 +1,56 @@
// +build windows

package apppaths

import (
"testing"
)

func TestPaths(t *testing.T) {
tests := []struct {
scopeType ScopeType
app string
dataDir string
cacheDir string
configFile string
logFile string
}{
{System, "foobar", "%PROGRAMDATA%/foobar", "%PROGRAMDATA%/foobar/Cache", "%PROGRAMDATA%/foobar/Config/foobar.conf", "%PROGRAMDATA%/foobar/Logs/foobar.log"},
{User, "foobar", "%LOCALAPPDATA%/foobar", "%LOCALAPPDATA%/foobar/Cache", "%LOCALAPPDATA%/foobar/Config/foobar.conf", "%LOCALAPPDATA%/foobar/Logs/foobar.log"},
}
for _, tt := range tests {
s := NewScope(tt.scopeType, "", tt.app)

path, err := s.DataDir()
if err != nil {
t.Errorf("Error retrieving data dir: %s", err)
}
if path != expandUser(tt.dataDir) {
t.Errorf("Expected data dir: %s - got: %s", tt.dataDir, path)
}

path, err = s.CacheDir()
if err != nil {
t.Errorf("Error retrieving cache dir: %s", err)
}
if path != expandUser(tt.cacheDir) {
t.Errorf("Expected cache dir: %s - got: %s", tt.cacheDir, path)
}

path, err = s.ConfigPath(tt.app + ".conf")
if err != nil {
t.Errorf("Error retrieving config path: %s", err)
}
if path != expandUser(tt.configFile) {
t.Errorf("Expected config path: %s - got: %s", tt.configFile, path)
}

path, err = s.LogPath(tt.app + ".log")
if err != nil {
t.Errorf("Error retrieving log path: %s", err)
}
if path != expandUser(tt.logFile) {
t.Errorf("Expected log path: %s - got: %s", tt.logFile, path)
}
}
}

0 comments on commit bb85ba7

Please sign in to comment.