Skip to content

Commit

Permalink
fix: Allow for more flexible flag key in tombstone (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 authored Nov 6, 2024
1 parent 9fecb01 commit 2a0e8e7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions sdktests/server_side_persistence_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newServerSidePersistentTests(
}

func (s *ServerSidePersistentTests) Run(t *ldtest.T) {
t.Run("uses default prefix", func(t *ldtest.T) {
s.runWithEmptyStore(t, "uses default prefix", func(t *ldtest.T) {
require.NoError(t, s.persistentStore.WriteMap(s.defaultPrefix, "features", s.initialFlags))

persistence := NewPersistence()
Expand All @@ -160,7 +160,7 @@ func (s *ServerSidePersistentTests) Run(t *ldtest.T) {
ldvalue.String("default"), ldvalue.String("fallthrough"), ldvalue.String("default"))
})

t.Run("uses custom prefix", func(t *ldtest.T) {
s.runWithEmptyStore(t, "uses custom prefix", func(t *ldtest.T) {
customPrefix := "custom-prefix"

persistence := NewPersistence()
Expand Down Expand Up @@ -456,14 +456,14 @@ func (s *ServerSidePersistentTests) Run(t *ldtest.T) {
// Lower versioned deletes are ignored
stream.StreamingService().PushDelete("flags", "flag-key", 1)
s.neverValidateFlagData(t, s.defaultPrefix, map[string]m.Matcher{
"flag-key": basicDeletedFlagValidationMatcher(1),
"flag-key": basicDeletedFlagValidationMatcher("flag-key", 1),
"uncached-flag-key": basicFlagValidationMatcher("uncached-flag-key", 100, "fallthrough"),
})

// Higher versioned deletes are applied
stream.StreamingService().PushDelete("flags", "flag-key", 200)
s.eventuallyValidateFlagData(t, s.defaultPrefix, map[string]m.Matcher{
"flag-key": basicDeletedFlagValidationMatcher(200),
"flag-key": basicDeletedFlagValidationMatcher("flag-key", 200),
"uncached-flag-key": basicFlagValidationMatcher("uncached-flag-key", 100, "fallthrough"),
})
})
Expand Down Expand Up @@ -673,9 +673,12 @@ func basicFlagValidationMatcher(key string, version int, value string) m.Matcher
)
}

func basicDeletedFlagValidationMatcher(version int) m.Matcher {
func basicDeletedFlagValidationMatcher(key string, version int) m.Matcher {
return m.AllOf(
m.JSONProperty("key").Should(m.Equal("$deleted")),
m.AnyOf(
m.JSONProperty("key").Should(m.Equal(key)),
m.JSONProperty("key").Should(m.Equal("$deleted")),
),
m.JSONProperty("version").Should(m.Equal(version)),
m.JSONProperty("deleted").Should(m.Equal(true)),
)
Expand Down

0 comments on commit 2a0e8e7

Please sign in to comment.