-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthsites_test.go
57 lines (47 loc) · 1.17 KB
/
authsites_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
package proxy
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_AuthSitesDecode(t *testing.T) {
assert := assert.New(t)
want := make(AuthSites)
input := ""
var got AuthSites
// Test empty string
err := got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
// Test multiple commas
input += ",,"
err = got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
// Test no colon
input = "www.example.com"
err = got.Decode(input)
assert.ErrorContains(err, "invalid input format")
// Test one value
input = "one:http://example.com"
want["one"] = "example.com:80"
err = got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
// Test with port
input += ",two:https://testing.com:7388"
want["two"] = "testing.com:7388"
err = got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
// Test no protocol
input += ",three:go.dev"
want["three"] = "go.dev:80"
err = got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
// Test extra comma
input += ","
err = got.Decode(input)
assert.NoError(err)
assert.NoError(assertEqual(want, got))
}