Skip to content

Commit

Permalink
add stop call to each test
Browse files Browse the repository at this point in the history
  • Loading branch information
ndurell committed Oct 4, 2024
1 parent d6c7938 commit 23c721c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Tests/KlaviyoSwiftTests/APIRequestErrorHandlingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class APIRequestErrorHandlingTests: XCTestCase {
@MainActor
override func setUp() async throws {
environment = KlaviyoEnvironment.test()
klaviyoSwiftEnvironment = KlaviyoSwiftEnvironment.test()
}

func cleanup(testStore: TestStore<KlaviyoReducer.State, KlaviyoReducer.Action, KlaviyoReducer.State, KlaviyoReducer.Action, Void>) async {
await testStore.send(.stop)

await testStore.receive(.cancelInFlightRequests)
}

// MARK: - http error
Expand All @@ -36,6 +43,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.requestsInFlight = []
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -61,6 +69,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -85,7 +94,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.requestsInFlight = []
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -110,6 +119,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(2)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -133,6 +143,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(2)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -158,6 +169,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -183,6 +195,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -207,6 +220,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -231,6 +245,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -254,6 +269,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -277,6 +293,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -300,6 +317,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retryWithBackoff(requestCount: 2, totalRetryCount: 2, currentBackoff: 30)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -322,6 +340,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retryWithBackoff(requestCount: 3, totalRetryCount: 3, currentBackoff: 30)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -344,6 +363,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retryWithBackoff(requestCount: 4, totalRetryCount: 4, currentBackoff: 20)
}

await cleanup(testStore: store)
await store.finish()
}

Expand All @@ -368,6 +388,7 @@ class APIRequestErrorHandlingTests: XCTestCase {
$0.retryInfo = .retry(1)
}

await cleanup(testStore: store)
await store.finish()
}
}

0 comments on commit 23c721c

Please sign in to comment.