From a9218a0982e47d82c44000e95e1b6f3ac16ac305 Mon Sep 17 00:00:00 2001 From: Matthew Keeler Date: Fri, 3 Jan 2025 15:36:46 -0500 Subject: [PATCH] fix: Remove invalid conditions from persistent tests --- sdktests/server_side_persistence_base.go | 66 +----------------------- 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/sdktests/server_side_persistence_base.go b/sdktests/server_side_persistence_base.go index ad5175d..7ba774a 100644 --- a/sdktests/server_side_persistence_base.go +++ b/sdktests/server_side_persistence_base.go @@ -572,72 +572,10 @@ func (s *ServerSidePersistentTests) Run(t *ldtest.T) { require.NoError(t, s.persistentStore.WriteMap(s.defaultPrefix, "features", s.initialFlags)) - if cacheConfig.Mode == servicedef.CacheModeInfinite { - // This key was already cached, so it shouldn't see the change above. - h.RequireNever(t, - checkForUpdatedValue(t, client, "flag-key", context, - ldvalue.String("value"), ldvalue.String("new-value"), ldvalue.String("default")), - time.Millisecond*500, time.Millisecond*20, "flag-key was incorrectly updated") - - // But since we didn't evaluate this flag, this should actually be - // reflected by directly changing the database. - h.RequireEventually(t, - checkForUpdatedValue(t, client, "uncached-flag-key", context, - ldvalue.String("default"), ldvalue.String("fallthrough"), ldvalue.String("default")), - time.Millisecond*500, time.Millisecond*20, "uncached-flag-key was incorrectly cached") - } else if cacheConfig.Mode == servicedef.CacheModeTTL { - // This key was already cached, so it shouldn't see the change above. - h.RequireNever(t, - checkForUpdatedValue(t, client, "flag-key", context, - ldvalue.String("value"), ldvalue.String("new-value"), ldvalue.String("default")), - time.Duration( - int(time.Second)*cacheConfig.TTL.Value()/2), - time.Millisecond*20, - "flag-key was incorrectly updated") - - // But eventually, it will expire and then we will fetch it from the database. - h.RequireEventually(t, - checkForUpdatedValue(t, client, "flag-key", context, - ldvalue.String("value"), ldvalue.String("fallthrough"), ldvalue.String("default")), - time.Duration(int(time.Second)*cacheConfig.TTL.Value()), time.Millisecond*20, "flag-key was incorrectly cached") - } - }) - - s.runWithEmptyStore(t, "ignores dropped flags", func(t *ldtest.T) { - persistence := NewPersistence() - persistence.SetStoreMode(servicedef.DataStoreModeReadWrite) - persistence.SetStore(servicedef.SDKConfigPersistentStore{ - Type: s.persistentStore.Type(), - DSN: s.persistentStore.DSN(), - }) - persistence.SetCache(cacheConfig) - - sdkData := s.makeSDKDataWithFlag(1, ldvalue.String("value")) - _, configurers := s.setupDataSystems(t, sdkData) - configurers = append(configurers, persistence) - - client := NewSDKClient(t, s.baseSDKConfigurationPlus(configurers...)...) - context := ldcontext.New("user-key") - s.eventuallyRequireDataStoreInit(t, s.defaultPrefix) - - pollUntilFlagValueUpdated(t, client, "flag-key", context, - ldvalue.String("default"), ldvalue.String("value"), ldvalue.String("default")) - - require.NoError(t, s.persistentStore.Reset()) - - // This key was already cached, so it shouldn't see the change above. h.RequireNever(t, checkForUpdatedValue(t, client, "flag-key", context, - ldvalue.String("value"), ldvalue.String("default"), ldvalue.String("default")), - time.Millisecond*500, time.Millisecond*20, "flag was never updated") - - if cacheConfig.Mode == servicedef.CacheModeTTL { - // But eventually, it will expire and then we will fetch it from the database. - h.RequireEventually(t, - checkForUpdatedValue(t, client, "flag-key", context, - ldvalue.String("value"), ldvalue.String("default"), ldvalue.String("default")), - time.Second, time.Millisecond*20, "flag-key was incorrectly cached") - } + ldvalue.String("value"), ldvalue.String("new-value"), ldvalue.String("default")), + time.Millisecond*500, time.Millisecond*20, "flag-key was incorrectly updated") }) }) }