package launch

import "testing"

func TestResolveMode(t *testing.T) {
	tests := []struct {
		name      string
		args      Args
		isService bool
		want      Mode
	}{
		{"gui by default", Args{}, false, ModeGUI},
		{"installer wins", Args{Install: true}, false, ModeInstallService},
		{"uninstaller wins", Args{Uninstall: true}, false, ModeUninstallService},
		{"prepare-upgrade wins", Args{PrepareUpgrade: true}, false, ModePrepareUpgrade},
		{"firewall wins over service", Args{Firewall: true}, true, ModeFirewall},
		{"subproc wins over service", Args{Subprocess: true}, true, ModeSubprocess},
		{"windows service when no explicit role", Args{}, true, ModeService},
	}

	for _, tt := range tests {
		got := ResolveMode(tt.args, tt.isService)
		if got != tt.want {
			t.Fatalf("%s: ResolveMode() = %q, want %q", tt.name, got, tt.want)
		}
	}
}
