Skip to content

Commit

Permalink
remove test, generate new api
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Jul 16, 2024
1 parent 6675ec3 commit cf003dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 39 deletions.
39 changes: 0 additions & 39 deletions Tests/ConfidenceTests/ConfidenceTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -617,45 +617,6 @@ class ConfidenceTest: XCTestCase {
XCTAssertEqual(error as? ConfidenceError, ConfidenceError.invalidContextInMessage)
}
}

func testRequestTimedOut() async throws {
class FakeClient: ConfidenceResolveClient {
var resolvedValues: [ResolvedValue] = []
func resolve(ctx: ConfidenceStruct) async throws -> ResolvesResult {
try await Task.sleep(nanoseconds: 5000000000)
return .init(resolvedValues: resolvedValues, resolveToken: "token")
}
}

let client = FakeClient()
client.resolvedValues = [
ResolvedValue(
variant: "default",
value: .init(structure: ["size": .init(integer: 3)]),
flag: "flag",
resolveReason: .match)
]

let confidence = Confidence.Builder(clientSecret: "test")
.withContext(initialContext: ["targeting_key": .init(string: "user2")])
.withFlagResolverClient(flagResolver: client)
.withFlagApplier(flagApplier: flagApplier)
.withTimeout(timeout: 1)
.build()

try await confidence.fetchAndActivate()
let evaluation = try confidence.getEvaluation(
key: "flag.size",
defaultValue: 0)

XCTAssertEqual(evaluation.value, 3)
XCTAssertNil(evaluation.errorCode)
XCTAssertNil(evaluation.errorMessage)
XCTAssertEqual(evaluation.reason, .match)
XCTAssertEqual(evaluation.variant, "default")
await fulfillment(of: [flagApplier.applyExpectation], timeout: 1)
XCTAssertEqual(flagApplier.applyCallCount, 1)
}
}

final class DispatchQueueFake: DispatchQueueType {
Expand Down
4 changes: 4 additions & 0 deletions api/Confidence_public_api.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"name": "withRegion(region:)",
"declaration": "public func withRegion(region: ConfidenceRegion) -> Builder"
},
{
"name": "withTimeout(timeout:)",
"declaration": "public func withTimeout(timeout: Double) -> Builder"
},
{
"name": "build()",
"declaration": "public func build() -> Confidence"
Expand Down
Empty file removed scripts/Confidence_raw_api.json
Empty file.

0 comments on commit cf003dd

Please sign in to comment.