Skip to content

Commit

Permalink
Improve testing on global events
Browse files Browse the repository at this point in the history
Signed-off-by: Fabrizio Demaria <[email protected]>
  • Loading branch information
fabriziodemaria committed Jan 22, 2024
1 parent 181ec34 commit e3029f7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Tests/OpenFeatureTests/DeveloperExperienceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ final class DeveloperExperienceTests: XCTestCase {
XCTAssertFalse(flagValue)
}

func testObserveProviderReady() {
func testObserveGlobalEvents() {
let readyExpectation = XCTestExpectation(description: "Ready")
let errorExpectation = XCTestExpectation(description: "Error")
let staleExpectation = XCTestExpectation(description: "Stale")
let eventState = OpenFeatureAPI.shared.observe().sink { event in
var eventState = OpenFeatureAPI.shared.observe().sink { event in
switch event {
case ProviderEvent.ready:
readyExpectation.fulfill()
Expand All @@ -35,8 +35,17 @@ final class DeveloperExperienceTests: XCTestCase {
XCTFail("Unexpected event")
}
}
OpenFeatureAPI.shared.setProvider(provider: DoSomethingProvider())
let provider = DoSomethingProvider()
OpenFeatureAPI.shared.setProvider(provider: provider)
wait(for: [readyExpectation], timeout: 5)

// Clearing the Provider shouldn't send further global events from it
eventState = OpenFeatureAPI.shared.observe().sink { event in

Check warning on line 43 in Tests/OpenFeatureTests/DeveloperExperienceTests.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Unused Closure Parameter Violation: Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
XCTFail("Unexpected event")
}
OpenFeatureAPI.shared.clearProvider()
provider.initialize(initialContext: MutableContext(attributes: ["Test": Value.string("Test")]))

XCTAssertNotNil(eventState)
}

Expand Down

0 comments on commit e3029f7

Please sign in to comment.