This repository has been archived on 2026-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
ollie-core/paths/paths_test.go

38 lines
860 B
Go

package paths
import (
"os"
"testing"
)
func TestCfgDirDefault(t *testing.T) {
home, _ := os.UserHomeDir()
if got := CfgDir(); got != home+"/.config/ollie" {
t.Errorf("CfgDir() = %q; want %s/.config/ollie", got, home)
}
}
func TestDataDirDefault(t *testing.T) {
home, _ := os.UserHomeDir()
if got := DataDir(); got != home+"/.local/share/ollie" {
t.Errorf("DataDir() = %q; want %s/.local/share/ollie", got, home)
}
}
func TestExpandHome(t *testing.T) {
home, _ := os.UserHomeDir()
tests := []struct{ in, want string }{
{"~", home},
{"~/src", home + "/src"},
{"/abs/path", "/abs/path"},
{"relative", "relative"},
{"~user/foo", "~user/foo"}, // only bare ~ is expanded
{"", ""},
}
for _, tt := range tests {
if got := ExpandHome(tt.in); got != tt.want {
t.Errorf("ExpandHome(%q) = %q; want %q", tt.in, got, tt.want)
}
}
}