Skip to content

Commit

Permalink
rename client to offline for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Jan 11, 2024
1 parent 542fc21 commit ead8341
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ public enum ConfidenceClientCredentials {
}
}

public enum ConfidenceRegion: String {
case global = "global"
case europe = "eu"
case usa = "us"
public enum ConfidenceRegion {
case global
case europe
case usa
}

struct Sdk: Codable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest
@testable import ConfidenceProvider

class ConfidenceIntegrationTests: XCTestCase {
let clientToken: String? = "5GdaBq79NMVrMGXRVhN9g1pBKtG9cNK8"
let clientToken: String? = ProcessInfo.processInfo.environment["CLIENT_TOKEN"]
let resolveFlag = setResolveFlag()
let storage: Storage = StorageMock()

Expand Down
16 changes: 8 additions & 8 deletions Tests/ConfidenceProviderTests/FlagApplierWithRetriesTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class FlagApplierWithRetriesTest: XCTestCase {

func testApply_multipleApplyCalls_batchTriggered() async throws {
// Given flag applier with http client that is offline
let httpClient = HttpClientMock(testMode: .error)
let httpClient = HttpClientMock(testMode: .offline)
let networkExpectation = self.expectation(description: "Waiting for batch trigger")
networkExpectation.expectedFulfillmentCount = 2
httpClient.expectation = networkExpectation
Expand Down Expand Up @@ -237,7 +237,7 @@ class FlagApplierWithRetriesTest: XCTestCase {
func testApply_multipleApplyCalls_sentSet() async throws {
// Given flag applier with http client that is offline
let cacheDataInteractor = CacheDataInteractor(cacheData: .empty())
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let networkExpectation = self.expectation(description: "Waiting for network call to complete")
networkExpectation.expectedFulfillmentCount = 2
offlineClient.expectation = networkExpectation
Expand Down Expand Up @@ -336,7 +336,7 @@ class FlagApplierWithRetriesTest: XCTestCase {
func testApply_previoslyStoredData_doesNotCleanAfterSendingFailure() throws {
// Given offline http client
// And storage that has previosly stored data (100 records, same token)
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let prefilledStorage = StorageMock()
let prefilledCache = try CacheDataUtility.prefilledCacheData(applyEventCount: 100)
try prefilledStorage.save(data: prefilledCache)
Expand All @@ -359,7 +359,7 @@ class FlagApplierWithRetriesTest: XCTestCase {

func testApplyOffline_storesOnDisk() async throws {
// Given offline http client and flag applier
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let applier = FlagApplierWithRetries(
httpClient: offlineClient, storage: storage, options: options, metadata: metadata, triggerBatch: false
)
Expand Down Expand Up @@ -388,7 +388,7 @@ class FlagApplierWithRetriesTest: XCTestCase {

func testApplyOffline_storesOnDisk_multipleTokens() async throws {
// Given offline http client and flag applier
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let applier = FlagApplierWithRetries(
httpClient: offlineClient, storage: storage, options: options, metadata: metadata, triggerBatch: false
)
Expand Down Expand Up @@ -416,7 +416,7 @@ class FlagApplierWithRetriesTest: XCTestCase {
func testApplyOffline_previoslyStoredData_storesOnDisk() async throws {
// Given flag applier set up with offline http client
// And storage that has previously stored 1 record
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let data = CacheData(resolveToken: "token0", flagName: "flag1", applyTime: Date(timeIntervalSince1970: 1000))
let prefilledStorage = try StorageMock(data: data)

Expand Down Expand Up @@ -453,7 +453,7 @@ class FlagApplierWithRetriesTest: XCTestCase {
func testApplyOffline_previoslyStoredData_100records() async throws {
// Given flag applier set up with offline http client
// And storage that has previously stored 100 records with different tokens
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let prefilledStorage = StorageMock()
let prefilledCache = try CacheDataUtility.prefilledCacheData(resolveEventCount: 100)
try prefilledStorage.save(data: prefilledCache)
Expand All @@ -477,7 +477,7 @@ class FlagApplierWithRetriesTest: XCTestCase {
func testApplyOffline_100applyCalls_sameToken() async throws {
// Given flag applier set up with offline http client
// And storage that has previously stored 100 records with same token
let offlineClient = HttpClientMock(testMode: .error)
let offlineClient = HttpClientMock(testMode: .offline)
let networkExpectation = self.expectation(description: "Waiting for networkRequest to be completed")

// Since we don't fail other requests when one request is failing
Expand Down
4 changes: 2 additions & 2 deletions Tests/ConfidenceProviderTests/Helpers/HttpClientMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class HttpClientMock: HttpClient {
enum TestMode {
case success
case failFirstChunk
case error
case offline
}

init(testMode: TestMode = .success) {
Expand Down Expand Up @@ -63,7 +63,7 @@ final class HttpClientMock: HttpClient {
} else {
return HttpClientResponse(response: HTTPURLResponse())
}
case .error:
case .offline:
throw HttpClientError.invalidResponse
}
}
Expand Down

0 comments on commit ead8341

Please sign in to comment.