Skip to content

Commit

Permalink
Fix Waiters protocol tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Oct 4, 2023
1 parent 0f94281 commit f99015e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ErrorTypeMatcherTests: XCTestCase {
}

func test_errorType_doesNotMatchWhenResultIsSuccess() async throws {
let response = GetWidgetOutputResponse()
let response = GetWidgetOutput()
let subject = try WaitersClient.errorTypeMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(response))
XCTAssertNil(match)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InputOutputMatcherTests: XCTestCase {
func test_inputOutput_acceptorMatchesWhenInputAndOutputPropertiesMatch() async throws {
let value = UUID().uuidString
let input = GetWidgetInput(stringProperty: value)
let output = GetWidgetOutputResponse(stringProperty: value)
let output = GetWidgetOutput(stringProperty: value)
let subject = try WaitersClient.inputOutputPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: input, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
Expand All @@ -30,7 +30,7 @@ class InputOutputMatcherTests: XCTestCase {
func test_inputOutput_acceptorFailsToMatchWhenInputAndOutputPropertiesDontMatch() async throws {
let value = UUID().uuidString
let input = GetWidgetInput(stringProperty: value)
let output = GetWidgetOutputResponse(stringProperty: value + "xxx")
let output = GetWidgetOutput(stringProperty: value + "xxx")
let subject = try WaitersClient.inputOutputPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: input, result: .success(output))
XCTAssertNil(match)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ class OutputMatcherTests: XCTestCase {
// JMESPath expected value: payload property contents

func test_outputStringProperty_acceptorMatchesOnPropertyMatch() async throws {
let output = GetWidgetOutputResponse(stringProperty: "payload property contents")
let output = GetWidgetOutput(stringProperty: "payload property contents")
let subject = try WaitersClient.outputStringPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_outputStringProperty_acceptorFailsToMatchOnPropertyMismatch() async throws {
let output = GetWidgetOutputResponse(stringProperty: "not the payload property contents")
let output = GetWidgetOutput(stringProperty: "not the payload property contents")
let subject = try WaitersClient.outputStringPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_outputStringProperty_acceptorFailsToMatchOnNullProperty() async throws {
let output = GetWidgetOutputResponse(stringProperty: nil)
let output = GetWidgetOutput(stringProperty: nil)
let subject = try WaitersClient.outputStringPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand All @@ -45,21 +45,21 @@ class OutputMatcherTests: XCTestCase {
// JMESPath expected value: false

func test_outputBooleanProperty_acceptorMatchesOnPropertyMatch() async throws {
let output = GetWidgetOutputResponse(booleanProperty: false)
let output = GetWidgetOutput(booleanProperty: false)
let subject = try WaitersClient.outputBooleanPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_outputBooleanProperty_acceptorFailsToMatchOnPropertyMismatch() async throws {
let output = GetWidgetOutputResponse(booleanProperty: true)
let output = GetWidgetOutput(booleanProperty: true)
let subject = try WaitersClient.outputBooleanPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_outputBooleanProperty_acceptorFailsToMatchOnNullProperty() async throws {
let output = GetWidgetOutputResponse(booleanProperty: nil)
let output = GetWidgetOutput(booleanProperty: nil)
let subject = try WaitersClient.outputBooleanPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand All @@ -73,29 +73,29 @@ class OutputMatcherTests: XCTestCase {

func test_arrayPropertyAll_acceptorMatchesWhenArrayElementsAllMatch() async throws {
let expected = "payload property contents"
let output = GetWidgetOutputResponse(stringArrayProperty: [expected, expected, expected])
let output = GetWidgetOutput(stringArrayProperty: [expected, expected, expected])
let subject = try WaitersClient.outputStringArrayAllPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_arrayPropertyAll_acceptorFailsToMatchWhenArrayElementsDontMatch() async throws {
let expected = "payload property contents"
let output = GetWidgetOutputResponse(stringArrayProperty: [expected, expected, "unexpected"])
let output = GetWidgetOutput(stringArrayProperty: [expected, expected, "unexpected"])
let subject = try WaitersClient.outputStringArrayAllPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_arrayPropertyAll_acceptorFailsToMatchWhenArrayIsEmpty() async throws {
let output = GetWidgetOutputResponse(stringArrayProperty: [])
let output = GetWidgetOutput(stringArrayProperty: [])
let subject = try WaitersClient.outputStringArrayAllPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_arrayPropertyAll_acceptorFailsToMatchWhenArrayIsNull() async throws {
let output = GetWidgetOutputResponse(stringArrayProperty: nil)
let output = GetWidgetOutput(stringArrayProperty: nil)
let subject = try WaitersClient.outputStringArrayAllPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand All @@ -109,37 +109,37 @@ class OutputMatcherTests: XCTestCase {

func test_arrayPropertyAny_acceptorMatchesWhenArrayElementsAllMatch() async throws {
let expected = "payload property contents"
let output = GetWidgetOutputResponse(stringArrayProperty: [expected, expected, expected])
let output = GetWidgetOutput(stringArrayProperty: [expected, expected, expected])
let subject = try WaitersClient.outputStringArrayAnyPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_arrayPropertyAny_acceptorMatchesWhenAllButOneElementMismatches() async throws {
let expected = "payload property contents"
let output = GetWidgetOutputResponse(stringArrayProperty: [expected, expected, "unexpected"])
let output = GetWidgetOutput(stringArrayProperty: [expected, expected, "unexpected"])
let subject = try WaitersClient.outputStringArrayAnyPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_arrayPropertyAny_acceptorFailsToMatchWhenAllElementsMismatch() async throws {
let unexpected = "unexpected"
let output = GetWidgetOutputResponse(stringArrayProperty: [unexpected, unexpected, unexpected])
let output = GetWidgetOutput(stringArrayProperty: [unexpected, unexpected, unexpected])
let subject = try WaitersClient.outputStringArrayAnyPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_arrayPropertyAny_acceptorFailsToMatchWhenArrayIsEmpty() async throws {
let output = GetWidgetOutputResponse(stringArrayProperty: [])
let output = GetWidgetOutput(stringArrayProperty: [])
let subject = try WaitersClient.outputStringArrayAnyPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

func test_arrayPropertyAny_acceptorFailsToMatchWhenArrayIsNull() async throws {
let output = GetWidgetOutputResponse(stringArrayProperty: nil)
let output = GetWidgetOutput(stringArrayProperty: nil)
let subject = try WaitersClient.outputStringArrayAnyPropertyMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand Down Expand Up @@ -226,14 +226,14 @@ class OutputMatcherTests: XCTestCase {
// JMESPath expected value: "abc"

func test_projection_acceptorMatchesWhenProjectedValuesMatchExpectation() async throws {
let output = GetWidgetOutputResponse(dataMap: ["x": "abc", "y": "abc", "z": "abc"])
let output = GetWidgetOutput(dataMap: ["x": "abc", "y": "abc", "z": "abc"])
let subject = try WaitersClient.projectionMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_projection_acceptorDoesNotMatchWhenProjectedValuesDontMatchExpectation() async throws {
let output = GetWidgetOutputResponse(dataMap: ["x": "abc", "y": "abc", "z": "def"])
let output = GetWidgetOutput(dataMap: ["x": "abc", "y": "abc", "z": "def"])
let subject = try WaitersClient.projectionMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand All @@ -246,14 +246,14 @@ class OutputMatcherTests: XCTestCase {
// JMESPath expected value: "true"

func test_containsNonLiteral_acceptorMatchesWhenStringPropertyIsFound() async throws {
let output = GetWidgetOutputResponse(dataMap: ["a": "abc", "b": "xyz"], stringProperty: "xyz")
let output = GetWidgetOutput(dataMap: ["a": "abc", "b": "xyz"], stringProperty: "xyz")
let subject = try WaitersClient.containsFieldMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_containsNonLiteral_acceptorDoesNotMatchWhenStringPropertyIsNotFound() async throws {
let output = GetWidgetOutputResponse(dataMap: ["a": "abc", "b": "xyz"], stringProperty: "def")
let output = GetWidgetOutput(dataMap: ["a": "abc", "b": "xyz"], stringProperty: "def")
let subject = try WaitersClient.containsFieldMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand All @@ -266,28 +266,28 @@ class OutputMatcherTests: XCTestCase {
// JMESPath expected value: "true"

func test_andInequality_acceptorMatchesWhenCountsAreThreeAndNotThree() async throws {
let output = GetWidgetOutputResponse(dataMap: ["a": "a", "b": "b", "c": "c"], stringArrayProperty: ["a", "b"])
let output = GetWidgetOutput(dataMap: ["a": "a", "b": "b", "c": "c"], stringArrayProperty: ["a", "b"])
let subject = try WaitersClient.andInequalityMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
}

func test_andInequality_acceptorDoesNotMatchWhenCountsAreNotThreeAndThree() async throws {
let output = GetWidgetOutputResponse(dataMap: ["a": "a", "b": "b"], stringArrayProperty: ["a", "b", "c"])
let output = GetWidgetOutput(dataMap: ["a": "a", "b": "b"], stringArrayProperty: ["a", "b", "c"])
let subject = try WaitersClient.andInequalityMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
}

// MARK: - Helper methods

private func outputTree(globalName: String? = nil, embeddedName: String? = "c", appendBonusKid: Bool = false) -> GetWidgetOutputResponse {
private func outputTree(globalName: String? = nil, embeddedName: String? = "c", appendBonusKid: Bool = false) -> GetWidgetOutput {
var grandchildren2: [WaitersClientTypes.Grandchild] = [
.init(name: embeddedName ?? globalName, number: 1),
.init(name: globalName ?? "d", number: 2)
]
if appendBonusKid { grandchildren2.append(.init(name: "bonus kid", number: 7))}
return GetWidgetOutputResponse(children: [
return GetWidgetOutput(children: [
.init(grandchildren: [
.init(name: globalName ?? "a", number: 3),
.init(name: globalName ?? "b", number: 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SuccessMatcherTests: XCTestCase {
}

func test_successTrue_acceptorMatchesOnOutput() async throws {
let output = GetWidgetOutputResponse()
let output = GetWidgetOutput()
let subject = try WaitersClient.successTrueMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertEqual(match, .success(.success(output)))
Expand All @@ -33,7 +33,7 @@ class SuccessMatcherTests: XCTestCase {
}

func test_successFalse_acceptorFailsToMatchOnOutput() async throws {
let output = GetWidgetOutputResponse()
let output = GetWidgetOutput()
let subject = try WaitersClient.successFalseMatcherWaiterConfig().acceptors[0]
let match = subject.evaluate(input: anInput, result: .success(output))
XCTAssertNil(match)
Expand Down

0 comments on commit f99015e

Please sign in to comment.