forked from redboxllc/scuttle
-
Notifications
You must be signed in to change notification settings - Fork 4
/
scuttle_config_test.go
51 lines (49 loc) · 953 Bytes
/
scuttle_config_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
package main
import "testing"
func Test_replacePort(t *testing.T) {
type args struct {
sourceURL string
original int
replacement int
}
tests := []struct {
name string
args args
want string
}{
{
name: "Happy flow",
args: args{
sourceURL: "http://localhost:15000",
original: 15000,
replacement: 15020,
},
want: "http://localhost:15020",
},
{
name: "Invalid URL",
args: args{
sourceURL: "notaurl^^ :15000",
original: 15000,
replacement: 15020,
},
want: "",
},
{
name: "Port not matching",
args: args{
sourceURL: "http://localhost:14000",
original: 15000,
replacement: 15020,
},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := replacePort(tt.args.sourceURL, tt.args.original, tt.args.replacement); got != tt.want {
t.Errorf("replacePort() = %v, want %v", got, tt.want)
}
})
}
}