(t *testing.T)
| 82 | } |
| 83 | |
| 84 | func TestSandboxUpdate(t *testing.T) { |
| 85 | ctx, db := testDB(t) |
| 86 | store := NewSandboxStore(db) |
| 87 | |
| 88 | if _, err := store.Create(ctx, api.Sandbox{ |
| 89 | ID: "2", |
| 90 | Labels: map[string]string{"lbl1": "existing"}, |
| 91 | Spec: &types.Any{TypeUrl: "1", Value: []byte{1}}, // will replace |
| 92 | Extensions: map[string]typeurl.Any{ |
| 93 | "ext2": &types.Any{TypeUrl: "url2", Value: []byte{4, 5, 6}}, // will append `ext1` |
| 94 | }, |
| 95 | Runtime: api.RuntimeOpts{Name: "test"}, // no change |
| 96 | Sandboxer: "test-sandboxer", // no change |
| 97 | }); err != nil { |
| 98 | t.Fatal(err) |
| 99 | } |
| 100 | |
| 101 | expectedSpec := types.Any{TypeUrl: "2", Value: []byte{3, 2, 1}} |
| 102 | |
| 103 | out, err := store.Update(ctx, api.Sandbox{ |
| 104 | ID: "2", |
| 105 | Labels: map[string]string{"lbl1": "new"}, |
| 106 | Spec: &expectedSpec, |
| 107 | Extensions: map[string]typeurl.Any{ |
| 108 | "ext1": &types.Any{TypeUrl: "url1", Value: []byte{1, 2}}, |
| 109 | }, |
| 110 | }, "labels.lbl1", "extensions.ext1", "spec") |
| 111 | if err != nil { |
| 112 | t.Fatal(err) |
| 113 | } |
| 114 | |
| 115 | expected := api.Sandbox{ |
| 116 | ID: "2", |
| 117 | Spec: &expectedSpec, |
| 118 | Labels: map[string]string{ |
| 119 | "lbl1": "new", |
| 120 | }, |
| 121 | Extensions: map[string]typeurl.Any{ |
| 122 | "ext1": &types.Any{TypeUrl: "url1", Value: []byte{1, 2}}, |
| 123 | "ext2": &types.Any{TypeUrl: "url2", Value: []byte{4, 5, 6}}, |
| 124 | }, |
| 125 | Runtime: api.RuntimeOpts{Name: "test"}, |
| 126 | Sandboxer: "test-sandboxer", |
| 127 | } |
| 128 | |
| 129 | assertEqualInstances(t, out, expected) |
| 130 | } |
| 131 | |
| 132 | func TestSandboxGetInvalid(t *testing.T) { |
| 133 | ctx, db := testDB(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…