@@ -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