2026-08-28 12:52:26 +03:00
|
|
|
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
|
|
|
|
|
}{
|
2026-08-28 13:26:50 +03:00
|
|
|
{`C:\Apps\SystemMonitorAgent.exe`, `c:\apps\systemmonitoragent.exe`, true},
|
|
|
|
|
{`C:\Apps\SystemMonitorAgent.exe`, `C:\Apps\copy.exe`, false},
|
2026-08-28 12:52:26 +03:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|