Skip to content

Commit

Permalink
fix: test case
Browse files Browse the repository at this point in the history
  • Loading branch information
duyhungtnn committed Jul 25, 2023
1 parent d87adc6 commit e7b8e5c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
5 changes: 0 additions & 5 deletions Bucketeer.xcodeproj/xcshareddata/xcschemes/Bucketeer.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@
BlueprintName = "BucketeerTests"
ReferencedContainer = "container:Bucketeer.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "BucketeerE2ETests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
1 change: 1 addition & 0 deletions Bucketeer/Sources/Public/BKTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ extension BKTClient {
BKTClient.default = nil
}

// Please make sure the BKTClient is initialize before access it
public static var shared: BKTClient {
get throws {
// We do not want to crash the SDK's consumer app on runtime by using fatalError().
Expand Down
26 changes: 13 additions & 13 deletions BucketeerTests/E2E/BucketeerE2ETests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ final class BucketeerE2ETests: XCTestCase {
try await super.tearDown()

try await BKTClient.shared.flush()
BKTClient.destroy()
try! BKTClient.destroy()

Check failure on line 28 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
UserDefaults.standard.removeObject(forKey: "bucketeer_user_evaluations_id")
try FileManager.default.removeItem(at: .database)
}

func testStringVariation() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 34 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
XCTAssertEqual(client.stringVariation(featureId: FEATURE_ID_STRING, defaultValue: ""), "value-1")
}

func testStringVariationDetail() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 39 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
let actual = client.evaluationDetails(featureId: FEATURE_ID_STRING)

assertEvaluation(actual: actual, expected: .init(
Expand All @@ -51,12 +51,12 @@ final class BucketeerE2ETests: XCTestCase {
}

func testIntVariation() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 54 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
XCTAssertEqual(client.intVariation(featureId: FEATURE_ID_INT, defaultValue: 0), 10)
}

func testIntVariationDetail() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 59 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
let actual = client.evaluationDetails(featureId: FEATURE_ID_INT)

assertEvaluation(actual: actual, expected: .init(
Expand All @@ -71,12 +71,12 @@ final class BucketeerE2ETests: XCTestCase {
}

func testDoubleVariation() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 74 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
XCTAssertEqual(client.doubleVariation(featureId: FEATURE_ID_DOUBLE, defaultValue: 0.1), 2.1)
}

func testDoubleVariationDetail() async throws {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 79 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
let actual = client.evaluationDetails(featureId: FEATURE_ID_DOUBLE)

assertEvaluation(actual: actual, expected: .init(
Expand All @@ -91,12 +91,12 @@ final class BucketeerE2ETests: XCTestCase {
}

func testBoolVariation() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 94 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
XCTAssertEqual(client.boolVariation(featureId: FEATURE_ID_BOOLEAN, defaultValue: false), true)
}

func testBoolVariationDetail() {
let client = BKTClient.shared
let client = try! BKTClient.shared

Check failure on line 99 in BucketeerTests/E2E/BucketeerE2ETests.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
let actual = client.evaluationDetails(featureId: FEATURE_ID_BOOLEAN)

assertEvaluation(actual: actual, expected: .init(
Expand All @@ -111,13 +111,13 @@ final class BucketeerE2ETests: XCTestCase {
}

func testJSONVariation() {
let client = BKTClient.shared
let client = try! BKTClient.shared
let json = client.jsonVariation(featureId: FEATURE_ID_JSON, defaultValue: [:])
XCTAssertEqual(json as? [String: String], ["key": "value-1"])
}

func testJSONVariationDetail() {
let client = BKTClient.shared
let client = try! BKTClient.shared
let actual = client.evaluationDetails(featureId: FEATURE_ID_JSON)

assertEvaluation(actual: actual, expected: .init(
Expand All @@ -132,7 +132,7 @@ final class BucketeerE2ETests: XCTestCase {
}

func testEvaluationUpdateFlow() async throws {
let client = BKTClient.shared
let client = try! BKTClient.shared
XCTAssertEqual(client.stringVariation(featureId: FEATURE_ID_STRING, defaultValue: ""), "value-1")

client.updateUserAttributes(attributes: ["app_version": "0.0.1"])
Expand All @@ -153,7 +153,7 @@ final class BucketeerE2ETests: XCTestCase {
}

func testTrack() async throws {
let client = BKTClient.shared
let client = try! BKTClient.shared
client.assert(expectedEventCount: 2)
client.track(goalId: GOAL_ID, value: GOAL_VALUE)
try await Task.sleep(nanoseconds: 1_000_000)
Expand Down
2 changes: 1 addition & 1 deletion BucketeerTests/E2E/E2ETestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension BKTClient {
static func initialize(config: BKTConfig, user: BKTUser, timeoutMillis: Int64 = 5000) async throws {
return try await withCheckedThrowingContinuation { continuation in
DispatchQueue.main.async {
self.initialize(config: config, user: user) { error in
try! self.initialize(config: config, user: user) { error in

Check failure on line 38 in BucketeerTests/E2E/E2ETestHelpers.swift

View workflow job for this annotation

GitHub Actions / lint

Force Try Violation: Force tries should be avoided (force_try)
if let error = error {
continuation.resume(throwing: error)
} else {
Expand Down

0 comments on commit e7b8e5c

Please sign in to comment.