11de3fb12b
Code review found 5 silently-ignored errors in ReElevate (UTF16 conversions and os.Getwd) plus unescaped argument quoting that breaks args containing literal `"`. Each error is now wrapped with a clear message; quotes are backslash-escaped per the MSVC argv convention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
866 B
Go
33 lines
866 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestIsAdmin_Smoke(t *testing.T) {
|
|
// Smoke test: IsAdmin returns a bool without panicking.
|
|
// We can't assert true/false without knowing the test environment,
|
|
// but we ensure the syscall path doesn't crash.
|
|
_ = IsAdmin()
|
|
}
|
|
|
|
func TestCmdNeedsAdmin_NoAdminFlags(t *testing.T) {
|
|
cases := []struct {
|
|
args []string
|
|
needsAdm bool
|
|
}{
|
|
{[]string{}, true}, // bare drover.exe → GUI mode → needs admin
|
|
{[]string{"check"}, false}, // diagnostic only, no driver
|
|
{[]string{"check", "--host", "x"}, false},
|
|
{[]string{"--version"}, false},
|
|
{[]string{"version"}, false},
|
|
{[]string{"update"}, false}, // self-update doesn't need driver
|
|
}
|
|
for _, c := range cases {
|
|
got := CmdNeedsAdmin(c.args)
|
|
if got != c.needsAdm {
|
|
t.Errorf("CmdNeedsAdmin(%v) = %v, want %v", c.args, got, c.needsAdm)
|
|
}
|
|
}
|
|
}
|