-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtoken_test.go
More file actions
29 lines (25 loc) · 781 Bytes
/
token_test.go
File metadata and controls
29 lines (25 loc) · 781 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
package selfupdate
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCanUseTokenForDomain(t *testing.T) {
fixtures := []struct {
origin, other string
valid bool
}{
{"http://gitlab.com", "http://gitlab.com", true},
{"http://gitlab.com/owner/repo", "http://gitlab.com/file", true},
{"http://gitlab.com/owner/repo", "http://download.gitlab.com/file", true},
{"http://api.gitlab.com", "http://gitlab.com", false},
{"http://api.gitlab.com/owner/repo", "http://gitlab.com/file", false},
{"", "http://gitlab.com/file", false},
}
for _, fixture := range fixtures {
t.Run("", func(t *testing.T) {
ok, err := canUseTokenForDomain(fixture.origin, fixture.other)
assert.NoError(t, err)
assert.Equal(t, fixture.valid, ok)
})
}
}