package web import ( "runtime" "testing" "gitgud.io/mike/mpv-manager/pkg/config" "gitgud.io/mike/mpv-manager/pkg/constants" "gitgud.io/mike/mpv-manager/pkg/installer" "gitgud.io/mike/mpv-manager/pkg/platform" "github.com/stretchr/testify/require" ) func TestInstallMethodsFollowPortableDestination(t *testing.T) { methods := []installer.InstallMethod{{ID: constants.MethodMPVBinary}, {ID: constants.MethodIINA}} apps := []config.InstalledApp{ {InstallMethod: constants.MethodMPVBinary, InstallPath: `C:\Users\agent\mpv`}, {InstallMethod: constants.MethodIINA, InstallPath: "/Applications/IINA.app"}, } require.Equal(t, methods[:1], filterInstalledMethods(methods, apps, `C:\Custom MPV`)) require.Empty(t, filterInstalledMethods(methods, apps, `c:/users/AGENT/mpv/`)) } func TestWindowsMethodCollectionKeepsOtherDestinationAvailable(t *testing.T) { if runtime.GOOS != "windows" { t.Skip("installation handler dispatch follows the native OS") } server, _ := newInstallPathTestServer(t) server.platform = &platform.Platform{OSType: "windows", Arch: "amd64"} require.NoError(t, config.AddInstalledApp(config.InstalledApp{ AppName: "MPV", AppType: "app", InstallMethod: constants.MethodMPVBinary, InstallPath: `C:\Existing MPV`, })) var methodIDs []string for _, method := range server.getInstallMethods() { methodIDs = append(methodIDs, method.ID) } require.Contains(t, methodIDs, constants.MethodMPVBinary) }