Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow for more flexible flag key in tombstone #256

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an issue I noticed when running the tests against a different local service, so I'm adding that on here.

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)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm throwing this up here because it was quick to implement, but we should stop and decide if we actually want this.

Should we update each integration to require that the key, when deleted, is updated to $deleted?

m.JSONProperty("key").Should(m.Equal("$deleted")),
),
m.JSONProperty("version").Should(m.Equal(version)),
m.JSONProperty("deleted").Should(m.Equal(true)),
)
Expand Down
Loading