forked from influxdata/chronograf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinks_test.go
60 lines (57 loc) · 1.09 KB
/
links_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
package server
import (
"reflect"
"testing"
)
func TestNewCustomLinks(t *testing.T) {
tests := []struct {
name string
args map[string]string
want []CustomLink
wantErr bool
}{
{
name: "Unknown error in NewCustomLinks",
args: map[string]string{
"cubeapple": "https://cube.apple",
},
want: []CustomLink{
{
Name: "cubeapple",
URL: "https://cube.apple",
},
},
},
{
name: "CustomLink missing Name",
args: map[string]string{
"": "https://cube.apple",
},
wantErr: true,
},
{
name: "CustomLink missing URL",
args: map[string]string{
"cubeapple": "",
},
wantErr: true,
},
{
name: "Missing protocol scheme",
args: map[string]string{
"cubeapple": ":k%8a#",
},
wantErr: true,
},
}
for _, tt := range tests {
got, err := NewCustomLinks(tt.args)
if (err != nil) != tt.wantErr {
t.Errorf("%q. NewCustomLinks() error = %v, wantErr %v", tt.name, err, tt.wantErr)
continue
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("%q. NewCustomLinks() = %v, want %v", tt.name, got, tt.want)
}
}
}