Skip to content

Commit

Permalink
fix: change STALE reason in case of context change
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Feb 8, 2024
1 parent aefe8ab commit 6d9ec6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@ public class ConfidenceFeatureProvider: FeatureProvider {
)
return evaluationResult
} catch ConfidenceError.cachedValueExpired {
return ProviderEvaluation(value: defaultValue, variant: nil, reason: Reason.stale.rawValue)
} catch {
return ProviderEvaluation(value: defaultValue,

Check warning on line 254 in Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Multiline Arguments Violation: Arguments should be either on the same line, or one per line (multiline_arguments)
variant: nil,

Check warning on line 255 in Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Indentation Width Violation: Code should be indented using one tab or 4 spaces (indentation_width)

Check warning on line 255 in Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
reason: Reason.error.rawValue,
errorCode: ErrorCode.providerNotReady
)}

Check warning on line 258 in Sources/ConfidenceProvider/ConfidenceFeatureProvider.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Statement Position Violation: Else and catch should be on the same line, one space after the previous declaration (statement_position)
catch {
throw error
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,10 @@ class ConfidenceFeatureProviderTest: XCTestCase {
context: MutableContext(targetingKey: "user1"))

XCTAssertEqual(evaluation.value, 0)
XCTAssertNil(evaluation.errorCode)
XCTAssertNil(evaluation.errorMessage)
XCTAssertNil(evaluation.variant)
XCTAssertEqual(evaluation.reason, Reason.stale.rawValue)
XCTAssertEqual(evaluation.errorCode, ErrorCode.providerNotReady)
XCTAssertEqual(evaluation.reason, Reason.error.rawValue)
XCTAssertEqual(MockedConfidenceClientURLProtocol.resolveStats, 1)

// TODO: Check this - how do we check for something not called?
Expand Down

0 comments on commit 6d9ec6c

Please sign in to comment.