forked from couchbaselabs/cbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry_test.go
47 lines (42 loc) · 884 Bytes
/
registry_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
package main
import (
"fmt"
"testing"
)
func TestServerIDValidation(t *testing.T) {
tests := map[string]bool{
"": false,
"/": false,
"/@thing": false,
"@thing": false,
"/something": false,
"master": true,
"something": true,
}
for testId, shouldBeOK := range tests {
err := validateServerId(testId)
isOK := err == nil
if shouldBeOK != isOK {
t.Errorf("Expected ok=%v for %v, got %v (%v)",
shouldBeOK, testId, isOK, err)
t.Fail()
}
}
}
func TestErrSlice(t *testing.T) {
tests := []struct {
e error
exp string
}{
{&errslice{}, "{Errors: }"},
{&errslice{fmt.Errorf("a")}, "{Errors: a}"},
{&errslice{fmt.Errorf("a"),
fmt.Errorf("b")}, "{Errors: a, b}"},
}
for _, tc := range tests {
if tc.e.Error() != tc.exp {
t.Errorf("Expected %q, got %q for %v",
tc.exp, tc.e.Error(), tc.e)
}
}
}