...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package instance
16
17 import "testing"
18
19 func TestParseConnName(t *testing.T) {
20 tests := []struct {
21 name string
22 want ConnName
23 }{
24 {
25 "project:region:instance",
26 ConnName{"project", "region", "instance"},
27 },
28 {
29 "google.com:project:region:instance",
30 ConnName{"google.com:project", "region", "instance"},
31 },
32 {
33 "project:instance",
34 ConnName{},
35 },
36 }
37
38 for _, tc := range tests {
39 c, err := ParseConnName(tc.name)
40 if err != nil && tc.want != (ConnName{}) {
41 t.Errorf("unexpected error: %e", err)
42 }
43 if c != tc.want {
44 t.Errorf("ParseConnName(%s) failed: want %v, got %v", tc.name, tc.want, err)
45 }
46 }
47 }
48
View as plain text