Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixing usage of generated mock to not require change to mock #413

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LaunchDarkly/GeneratedCode/mocks.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ final class EventReportingMock: EventReporting {
}

var recordFlagEvaluationEventsCallCount = 0
var recordFlagEvaluationEventsCallback: ((_ event: FeatureEvent) throws -> Void)?
var recordFlagEvaluationEventsCallback: (() throws -> Void)?
var recordFlagEvaluationEventsReceivedArguments: (flagKey: LDFlagKey, value: LDValue, defaultValue: LDValue, featureFlag: FeatureFlag?, context: LDContext, includeReason: Bool)?
func recordFlagEvaluationEvents(flagKey: LDFlagKey, value: LDValue, defaultValue: LDValue, featureFlag: FeatureFlag?, context: LDContext, includeReason: Bool) {
recordFlagEvaluationEventsCallCount += 1
recordFlagEvaluationEventsReceivedArguments = (flagKey: flagKey, value: value, defaultValue: defaultValue, featureFlag: featureFlag, context: context, includeReason: includeReason)
try! recordFlagEvaluationEventsCallback?(FeatureEvent(key: flagKey, context: context, value: value, defaultValue: defaultValue, featureFlag: featureFlag, includeReason: includeReason, isDebug: false))
try! recordFlagEvaluationEventsCallback?()
}

var flushCallCount = 0
Expand Down
8 changes: 6 additions & 2 deletions LaunchDarkly/LaunchDarklyTests/LDClientSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,14 @@ final class LDClientSpec: QuickSpec {
let flagAC = FeatureFlag(flagKey: "flagAC", value: LDValue.bool(true), trackEvents: false, trackReason: false, prerequisites: ["flagA"])
let flagABD = FeatureFlag(flagKey: "flagABD", value: LDValue.bool(true), trackEvents: false, trackReason: false, prerequisites: ["flagAB"])
let flags: [LDFlagKey: FeatureFlag] = ["flagA": flagA, "flagAB": flagAB, "flagAC": flagAC, "flagABD": flagABD]
var storedItems = StoredItems(items: flags)
let storedItems = StoredItems(items: flags)
testContext.flagStoreMock.replaceStore(newStoredItems: storedItems)
var events = [FeatureEvent]()
testContext.eventReporterMock.recordFlagEvaluationEventsCallback = { events.append($0) }
testContext.eventReporterMock.recordFlagEvaluationEventsCallback = {
let args = testContext.eventReporterMock.recordFlagEvaluationEventsReceivedArguments!
let event = FeatureEvent(key: args.flagKey, context: args.context, value: args.value, defaultValue: args.defaultValue, featureFlag: args.featureFlag, includeReason: args.includeReason, isDebug: false)
events.append(event)
}
_ = testContext.subject.boolVariation(forKey: "flagA", defaultValue: DefaultFlagValues.bool)
_ = testContext.subject.boolVariation(forKey: "flagAB", defaultValue: DefaultFlagValues.bool)
_ = testContext.subject.boolVariation(forKey: "flagAC", defaultValue: DefaultFlagValues.bool)
Expand Down
Loading