Files
santifer--career-ops/dashboard/open_windows_test.go
T
wehub-resource-sync d083df1fdb
CodeQL Analysis / Analyze (javascript-typescript) (push) Failing after 2s
Web CI / web typecheck + build (push) Failing after 1s
Release Please / release-please (push) Failing after 1s
CodeQL Analysis / Analyze (go) (push) Failing after 16s
chore: import upstream snapshot with attribution
2026-07-13 12:02:43 +08:00

45 lines
1.0 KiB
Go

//go:build windows
package main
import (
"testing"
"golang.org/x/sys/windows"
)
func TestOpenWithDefaultAppWindowsUsesShellExecute(t *testing.T) {
previous := shellExecute
defer func() { shellExecute = previous }()
var called bool
var gotVerb string
var gotFile string
var gotShowCmd int32
shellExecute = func(_ windows.Handle, verb *uint16, file *uint16, _ *uint16, _ *uint16, showCmd int32) error {
called = true
gotVerb = windows.UTF16PtrToString(verb)
gotFile = windows.UTF16PtrToString(file)
gotShowCmd = showCmd
return nil
}
target := "https://example.com/jobs?id=1&next=calc"
if err := openWithDefaultApp(target); err != nil {
t.Fatalf("openWithDefaultApp returned error: %v", err)
}
if !called {
t.Fatal("ShellExecuteW was not called")
}
if gotVerb != "open" {
t.Fatalf("verb = %q, want open", gotVerb)
}
if gotFile != target {
t.Fatalf("file = %q, want exact target %q", gotFile, target)
}
if gotShowCmd != windows.SW_SHOWNORMAL {
t.Fatalf("showCmd = %d, want %d", gotShowCmd, windows.SW_SHOWNORMAL)
}
}