MCPcopy
hub / github.com/helm/helm / TestMemoryUpdate

Function TestMemoryUpdate

pkg/storage/driver/memory_test.go:185–239  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestMemoryUpdate(t *testing.T) {
186 var tests = []struct {
187 desc string
188 key string
189 rls *rspb.Release
190 err bool
191 }{
192 {
193 "update release status",
194 "rls-a.v4",
195 releaseStub("rls-a", 4, "default", common.StatusSuperseded),
196 false,
197 },
198 {
199 "update release does not exist",
200 "rls-c.v1",
201 releaseStub("rls-c", 1, "default", common.StatusUninstalled),
202 true,
203 },
204 {
205 "update release status in namespace",
206 "rls-c.v4",
207 releaseStub("rls-c", 4, "mynamespace", common.StatusSuperseded),
208 false,
209 },
210 {
211 "update release in namespace does not exist",
212 "rls-a.v1",
213 releaseStub("rls-a", 1, "mynamespace", common.StatusUninstalled),
214 true,
215 },
216 }
217
218 ts := tsFixtureMemory(t)
219 for _, tt := range tests {
220 if err := ts.Update(tt.key, tt.rls); err != nil {
221 if !tt.err {
222 t.Fatalf("Failed %q: %s\n", tt.desc, err)
223 }
224 continue
225 } else if tt.err {
226 t.Fatalf("Did not get expected error for %q '%s'\n", tt.desc, tt.key)
227 }
228
229 ts.SetNamespace(tt.rls.Namespace)
230 r, err := ts.Get(tt.key)
231 if err != nil {
232 t.Fatalf("Failed to get: %s\n", err)
233 }
234
235 if !reflect.DeepEqual(r, tt.rls) {
236 t.Fatalf("Expected %v, actual %v\n", tt.rls, r)
237 }
238 }
239}
240
241func TestMemoryDelete(t *testing.T) {
242 var tests = []struct {

Callers

nothing calls this directly

Calls 6

tsFixtureMemoryFunction · 0.85
FatalfMethod · 0.80
releaseStubFunction · 0.70
UpdateMethod · 0.65
GetMethod · 0.65
SetNamespaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…