Files

43 lines
992 B
Go
Raw Permalink Normal View History

package install
import (
"path/filepath"
"testing"
"tea.chunkbyte.com/kato/go-worm/lib/config"
)
func TestSamePath(t *testing.T) {
t.Parallel()
cases := []struct {
a, b string
want bool
}{
{`C:\Apps\win64_mp.exe`, `c:\apps\win64_mp.exe`, true},
{`C:\Apps\win64_mp.exe`, `C:\Apps\copy.exe`, false},
}
for _, tc := range cases {
if got := samePath(tc.a, tc.b); got != tc.want {
t.Fatalf("samePath(%q, %q) = %v, want %v", tc.a, tc.b, got, tc.want)
}
}
}
func TestInstalledExeName(t *testing.T) {
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
dir, err := config.InstallDir()
if err != nil {
t.Fatalf("InstallDir: %v", err)
}
exe, err := config.InstalledExe()
if err != nil {
t.Fatalf("InstalledExe: %v", err)
}
if filepath.Base(exe) != config.InstalledExeName {
t.Fatalf("InstalledExe base = %q, want %q", filepath.Base(exe), config.InstalledExeName)
}
if filepath.Dir(exe) != dir {
t.Fatalf("InstalledExe dir = %q, want %q", filepath.Dir(exe), dir)
}
}