(t *testing.T)
| 30 | } |
| 31 | |
| 32 | func TestMetadataCreateGetRemove(t *testing.T) { |
| 33 | testDir := t.TempDir() |
| 34 | testee := metadataStore{root: testDir, config: testCfg} |
| 35 | expected2 := Metadata{ |
| 36 | Endpoints: map[string]any{ |
| 37 | "ep1": endpoint{Foo: "baz"}, |
| 38 | "ep2": endpoint{Foo: "bee"}, |
| 39 | }, |
| 40 | Metadata: context{Bar: "foo"}, |
| 41 | Name: "test-context", |
| 42 | } |
| 43 | testMeta := testMetadata("test-context") |
| 44 | err := testee.createOrUpdate(testMeta) |
| 45 | assert.NilError(t, err) |
| 46 | // create a new instance to check it does not depend on some sort of state |
| 47 | testee = metadataStore{root: testDir, config: testCfg} |
| 48 | meta, err := testee.get("test-context") |
| 49 | assert.NilError(t, err) |
| 50 | assert.DeepEqual(t, meta, testMeta) |
| 51 | |
| 52 | // update |
| 53 | |
| 54 | err = testee.createOrUpdate(expected2) |
| 55 | assert.NilError(t, err) |
| 56 | meta, err = testee.get("test-context") |
| 57 | assert.NilError(t, err) |
| 58 | assert.DeepEqual(t, meta, expected2) |
| 59 | |
| 60 | assert.NilError(t, testee.remove("test-context")) |
| 61 | assert.NilError(t, testee.remove("test-context")) // support duplicate remove |
| 62 | _, err = testee.get("test-context") |
| 63 | assert.ErrorType(t, err, errdefs.IsNotFound) |
| 64 | } |
| 65 | |
| 66 | func TestMetadataRespectJsonAnnotation(t *testing.T) { |
| 67 | testDir := t.TempDir() |
nothing calls this directly
no test coverage detected
searching dependent graphs…