MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / Test_parseKeyspace

Function Test_parseKeyspace

rest/handler_test.go:87–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func Test_parseKeyspace(t *testing.T) {
88 tests := []struct {
89 ks string
90 wantDb string
91 wantScope *string
92 wantCollection *string
93 wantErr assert.ErrorAssertionFunc
94 }{
95 {
96 ks: "db",
97 wantDb: "db",
98 wantScope: nil,
99 wantCollection: nil,
100 wantErr: assert.NoError,
101 },
102 {
103 ks: "d.c",
104 wantDb: "d",
105 wantScope: nil,
106 wantCollection: base.Ptr("c"),
107 wantErr: assert.NoError,
108 },
109 {
110 ks: "d.s.c",
111 wantDb: "d",
112 wantScope: base.Ptr("s"),
113 wantCollection: base.Ptr("c"),
114 wantErr: assert.NoError,
115 },
116 {
117 ks: "",
118 wantErr: assert.Error,
119 },
120 {
121 ks: "d.s.c.z",
122 wantErr: assert.Error,
123 },
124 {
125 ks: ".s.",
126 wantErr: assert.Error,
127 },
128 {
129 ks: "d..c",
130 wantErr: assert.Error,
131 },
132 {
133 ks: "d.",
134 wantErr: assert.Error,
135 },
136 }
137 for _, tt := range tests {
138 t.Run(tt.ks, func(t *testing.T) {
139 gotDb, gotScope, gotCollection, err := ParseKeyspace(tt.ks)
140 if !tt.wantErr(t, err, fmt.Sprintf("ParseKeyspace(%v)", tt.ks)) {
141 return
142 }
143 assert.Equalf(t, tt.wantDb, gotDb, "ParseKeyspace(%v)", tt.ks)
144 assert.Equalf(t, tt.wantScope, gotScope, "ParseKeyspace(%v)", tt.ks)

Callers

nothing calls this directly

Calls 3

PtrFunction · 0.92
ParseKeyspaceFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected