...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package util
16
17 import "testing"
18
19 func TestSplitName(t *testing.T) {
20 table := []struct{ in, wantProj, wantRegion, wantInstance string }{
21 {"proj:region:my-db", "proj", "region", "my-db"},
22 {"google.com:project:region:instance", "google.com:project", "region", "instance"},
23 {"google.com:missing:part", "google.com:missing", "", "part"},
24 }
25
26 for _, test := range table {
27 gotProj, gotRegion, gotInstance := SplitName(test.in)
28 if gotProj != test.wantProj {
29 t.Errorf("splitName(%q): got %v for project, want %v", test.in, gotProj, test.wantProj)
30 }
31 if gotRegion != test.wantRegion {
32 t.Errorf("splitName(%q): got %v for region, want %v", test.in, gotRegion, test.wantRegion)
33 }
34 if gotInstance != test.wantInstance {
35 t.Errorf("splitName(%q): got %v for instance, want %v", test.in, gotInstance, test.wantInstance)
36 }
37 }
38 }
39
View as plain text