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

Function TestOpenContainingFolder_Validation

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

Source from the content-addressed store, hash-verified

45}
46
47func TestOpenContainingFolder_Validation(t *testing.T) {
48 tests := []struct {
49 name string
50 path string
51 errorHints []string
52 }{
53 {
54 name: "empty path",
55 path: "",
56 errorHints: []string{"empty"},
57 },
58 {
59 name: "dot path",
60 path: ".",
61 errorHints: []string{"cannot resolve"},
62 },
63 }
64
65 for _, tc := range tests {
66 t.Run(tc.name, func(t *testing.T) {
67 err := OpenContainingFolder(tc.path)
68 if err == nil {
69 t.Fatalf("expected validation error for %q", tc.path)
70 }
71
72 lower := strings.ToLower(err.Error())
73 for _, hint := range tc.errorHints {
74 if strings.Contains(lower, strings.ToLower(hint)) {
75 return
76 }
77 }
78
79 t.Fatalf("expected error containing one of %v, got: %v", tc.errorHints, err)
80 })
81 }
82}
83
84func TestOpenBrowser_Validation(t *testing.T) {
85 tests := []struct {

Callers

nothing calls this directly

Calls 2

OpenContainingFolderFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected