Skip to content

Commit

Permalink
fix: Remove STALE event
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Demaria <[email protected]>
  • Loading branch information
fabriziodemaria committed Feb 7, 2024
1 parent 523776a commit 1905ba2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ class ConfidenceFeatureProvider private constructor(
newContext: EvaluationContext
) {
if (newContext != oldContext) {
eventHandler.publish(OpenFeatureEvents.ProviderStale)

// on the new context we want to fetch new values and update
// the storage & cache right away which is why we pass `InitialisationStrategy.FetchAndActivate`
internalInitialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import dev.openfeature.sdk.ImmutableContext
import dev.openfeature.sdk.ImmutableStructure
import dev.openfeature.sdk.Reason
import dev.openfeature.sdk.Value
import dev.openfeature.sdk.events.EventHandler
import dev.openfeature.sdk.events.OpenFeatureEvents
import dev.openfeature.sdk.events.awaitReadyOrError
import junit.framework.TestCase
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -64,13 +62,12 @@ class StorageFileCacheTests {
whenever(mockContext.filesDir).thenReturn(Files.createTempDirectory("tmpTests").toFile())
}

@OptIn(ExperimentalCoroutinesApi::class)
@Test
fun testOfflineScenarioLoadsStoredCache() = runTest {
val mockClient: ConfidenceClient = mock()
whenever(mockClient.apply(any(), any())).thenReturn(Result.Success)
val testDispatcher = UnconfinedTestDispatcher(testScheduler)
val eventPublisher = EventHandler(testDispatcher)
eventPublisher.publish(OpenFeatureEvents.ProviderStale)
val cache1 = InMemoryCache()
whenever(mockClient.resolve(eq(listOf()), any())).thenReturn(
ResolveResponse.Resolved(
Expand All @@ -81,7 +78,6 @@ class StorageFileCacheTests {
context = mockContext,
clientSecret = "",
client = mockClient,
eventHandler = eventPublisher,
cache = cache1
)
provider1.initialize(ImmutableContext(targetingKey = "user1"))
Expand Down

0 comments on commit 1905ba2

Please sign in to comment.