forked from pkg/browser
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathbrowser_linux_test.go
More file actions
44 lines (41 loc) · 973 Bytes
/
browser_linux_test.go
File metadata and controls
44 lines (41 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package browser
import (
"slices"
"testing"
)
func TestProvidersForUrl(t *testing.T) {
tests := []struct {
name string
url string
want []string
}{
{
name: "http protocol",
url: "http://example.com",
want: []string{"xdg-open", "x-www-browser", "www-browser", "explorer.exe", "wslview"},
},
{
name: "https protocol",
url: "https://example.com",
want: []string{"xdg-open", "x-www-browser", "www-browser", "explorer.exe", "wslview"},
},
{
name: "file protocol",
url: "file:///path/to/file",
want: []string{"xdg-open", "x-www-browser", "www-browser", "wslview"},
},
{
name: "no protocol",
url: "example.sh",
want: []string{"xdg-open", "x-www-browser", "www-browser", "wslview"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := providersForUrl(tt.url)
if !slices.Equal(got, tt.want) {
t.Errorf("providersForUrl(%q) = %v; want %v", tt.url, got, tt.want)
}
})
}
}