Skip to content

Commit 0661c87

Browse files
committed
fixup: metadata test
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
1 parent e411624 commit 0661c87

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

core/pkg/store/store_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,31 @@ func TestGetAllWithWatcher(t *testing.T) {
448448
})
449449
}
450450
}
451+
452+
func TestQueryMetadata(t *testing.T) {
453+
454+
sourceA := "sourceA"
455+
otherSource := "otherSource"
456+
nonExistingFlagSetId := "nonExistingFlagSetId"
457+
var sources = []string{sourceA}
458+
sourceAFlags := map[string]model.Flag{
459+
"flagA": {Key: "flagA", DefaultVariant: "off"},
460+
"flagB": {Key: "flagB", DefaultVariant: "on"},
461+
}
462+
463+
store, err := NewStore(logger.NewLogger(nil, false), sources)
464+
if err != nil {
465+
t.Fatalf("NewStore failed: %v", err)
466+
}
467+
468+
// setup initial flags
469+
store.Update(sourceA, sourceAFlags, model.Metadata{})
470+
471+
selector := NewSelector("source=" + otherSource + ",flagSetId=" + nonExistingFlagSetId)
472+
_, metadata, _ := store.GetAll(context.Background(), &selector, nil)
473+
assert.Equal(t, metadata, model.Metadata{"source": otherSource, "flagSetId": nonExistingFlagSetId}, "metadata did not match expected")
474+
475+
selector = NewSelector("source=" + otherSource + ",flagSetId=" + nonExistingFlagSetId)
476+
_, metadata, _ = store.Get(context.Background(), "key", &selector)
477+
assert.Equal(t, metadata, model.Metadata{"source": otherSource, "flagSetId": nonExistingFlagSetId}, "metadata did not match expected")
478+
}

0 commit comments

Comments
 (0)