MCPcopy
hub / github.com/SurgeDM/Surge / TestOpenBrowser_Validation

Function TestOpenBrowser_Validation

internal/utils/open_test.go:84–119  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

82}
83
84func TestOpenBrowser_Validation(t *testing.T) {
85 tests := []struct {
86 name string
87 url string
88 errorHints []string
89 }{
90 {
91 name: "empty url",
92 url: "",
93 errorHints: []string{"empty"},
94 },
95 {
96 name: "whitespace url",
97 url: " ",
98 errorHints: []string{"empty"},
99 },
100 }
101
102 for _, tc := range tests {
103 t.Run(tc.name, func(t *testing.T) {
104 err := OpenBrowser(tc.url)
105 if err == nil {
106 t.Fatalf("expected validation error for %q", tc.url)
107 }
108
109 lower := strings.ToLower(err.Error())
110 for _, hint := range tc.errorHints {
111 if strings.Contains(lower, strings.ToLower(hint)) {
112 return
113 }
114 }
115
116 t.Fatalf("expected error containing one of %v, got: %v", tc.errorHints, err)
117 })
118 }
119}

Callers

nothing calls this directly

Calls 2

OpenBrowserFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected