Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} |