-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrabbit_test.go
More file actions
47 lines (45 loc) · 971 Bytes
/
grabbit_test.go
File metadata and controls
47 lines (45 loc) · 971 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
45
46
47
package main
import "testing"
func Test_validateImageURL(t *testing.T) {
t.Parallel()
type args struct {
fullURL string
}
tests := []struct {
name string
args args
want string
wantErr bool
}{
{
name: "bare",
args: args{fullURL: "https://example.com/img.jpeg"},
want: "img.jpeg",
wantErr: false,
},
{
name: "query",
args: args{fullURL: "https://example.com/img.jpeg?abc=def"},
want: "img.jpeg",
wantErr: false,
},
{
name: "bad",
args: args{fullURL: "https://example.com/hellodarknessmyoldfriend"},
want: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := validateImageURL(tt.args.fullURL)
if (err != nil) != tt.wantErr {
t.Errorf("validateImageURL() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("validateImageURL() = %v, want %v", got, tt.want)
}
})
}
}