Skip to content

Commit

Permalink
Removed surplus test
Browse files Browse the repository at this point in the history
  • Loading branch information
mildm8nnered committed Jul 16, 2023
1 parent 6f3ef9c commit c360b55
Showing 1 changed file with 12 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,56 +380,30 @@ extension ConfigurationTests {
}
}

private struct OptedInAndDisabledInChildTestCase: Equatable {
let optedInInChild: Bool
let disabledInChild: Bool
let isEnabled: Bool
}

func testParentOnlyRulesAndChildOptInAndDisabled() {
let testCases: [OptedInAndDisabledInChildTestCase] = [
OptedInAndDisabledInChildTestCase(optedInInChild: false, disabledInChild: false, isEnabled: true),
OptedInAndDisabledInChildTestCase(optedInInChild: true, disabledInChild: false, isEnabled: true),
OptedInAndDisabledInChildTestCase(optedInInChild: false, disabledInChild: true, isEnabled: false),
OptedInAndDisabledInChildTestCase(optedInInChild: true, disabledInChild: true, isEnabled: false)
]
XCTAssertEqual(testCases.unique.count, 2 * 2)
let ruleType = ImplicitReturnRule.self
let parentConfiguration = Configuration(rulesMode: .only([ruleType.description.identifier]))
testParentConfigurationAndChildOptInAndDisabled(
parentConfiguration, ruleType: ruleType, testCases: testCases
)
}

func testParentAllRulesAndChildOptInAndDisabled() {
let testCases: [OptedInAndDisabledInChildTestCase] = [
OptedInAndDisabledInChildTestCase(optedInInChild: false, disabledInChild: false, isEnabled: true),
OptedInAndDisabledInChildTestCase(optedInInChild: true, disabledInChild: false, isEnabled: true),
OptedInAndDisabledInChildTestCase(optedInInChild: false, disabledInChild: true, isEnabled: false),
OptedInAndDisabledInChildTestCase(optedInInChild: true, disabledInChild: true, isEnabled: false)
struct TestCase: Equatable {
let optedInInChild: Bool
let disabledInChild: Bool
let isEnabled: Bool
}
let testCases: [TestCase] = [
TestCase(optedInInChild: false, disabledInChild: false, isEnabled: true),
TestCase(optedInInChild: true, disabledInChild: false, isEnabled: true),
TestCase(optedInInChild: false, disabledInChild: true, isEnabled: false),
TestCase(optedInInChild: true, disabledInChild: true, isEnabled: false)
]
XCTAssertEqual(testCases.unique.count, 2 * 2)
let ruleType = ImplicitReturnRule.self
let parentConfiguration = Configuration(rulesMode: .allEnabled)
testParentConfigurationAndChildOptInAndDisabled(
parentConfiguration, ruleType: ruleType, testCases: testCases
)
}

private func testParentConfigurationAndChildOptInAndDisabled(
_ parentConfiguration: Configuration,
ruleType: Rule.Type,
testCases: [OptedInAndDisabledInChildTestCase]
) {
let ruleIdentifier = ruleType.description.identifier
let parentConfiguration = Configuration(rulesMode: .only([ruleIdentifier]))
for testCase in testCases {
let childConfiguration = Configuration(rulesMode: .default(
disabled: testCase.disabledInChild ? [ruleIdentifier] : [],
optIn: testCase.optedInInChild ? [ruleIdentifier] : []
))
let mergedConfiguration = parentConfiguration.merged(withChild: childConfiguration, rootDirectory: "")
let isEnabled = mergedConfiguration.contains(rule: ruleType)
let message = "optedInInChild = \(testCase.optedInInChild), disabledInChild = \(testCase.disabledInChild)"
let message = "optedInInChild = \(testCase.optedInInChild) disabledInChild = \(testCase.disabledInChild)"
XCTAssertEqual(isEnabled, testCase.isEnabled, message)
}
}
Expand Down

0 comments on commit c360b55

Please sign in to comment.