(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func 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 | |
| 84 | func TestOpenBrowser_Validation(t *testing.T) { |
| 85 | tests := []struct { |
nothing calls this directly
no test coverage detected