|
| 1 | +// |
| 2 | +// Copyright Amazon.com Inc. or its affiliates. |
| 3 | +// All Rights Reserved. |
| 4 | +// |
| 5 | +// SPDX-License-Identifier: Apache-2.0 |
| 6 | +// |
| 7 | + |
| 8 | +import ClientRuntime |
| 9 | +import XCTest |
| 10 | +@testable import Waiters |
| 11 | +@testable import SmithyWaitersAPI |
| 12 | + |
| 13 | +class OrMatcherTests: XCTestCase { |
| 14 | + |
| 15 | + // MARK: - OR expression with boolean and string comparison |
| 16 | + |
| 17 | + // JMESPath expression: "booleanProperty || stringProperty == 'match'" |
| 18 | + // JMESPath comparator: "booleanEquals" |
| 19 | + // JMESPath expected value: "true" |
| 20 | + |
| 21 | + func test_orBoolean_acceptorMatchesWhenBooleanIsTrue() async throws { |
| 22 | + let output = GetWidgetOutput(booleanProperty: true, stringProperty: "no match") |
| 23 | + let subject = try WaitersClient.orBooleanMatcherWaiterConfig().acceptors[0] |
| 24 | + let match = subject.evaluate(input: anInput, result: .success(output)) |
| 25 | + XCTAssertEqual(match, .success(.success(output))) |
| 26 | + } |
| 27 | + |
| 28 | + func test_orBoolean_acceptorMatchesWhenStringMatches() async throws { |
| 29 | + let output = GetWidgetOutput(booleanProperty: false, stringProperty: "match") |
| 30 | + let subject = try WaitersClient.orBooleanMatcherWaiterConfig().acceptors[0] |
| 31 | + let match = subject.evaluate(input: anInput, result: .success(output)) |
| 32 | + XCTAssertEqual(match, .success(.success(output))) |
| 33 | + } |
| 34 | + |
| 35 | + func test_orBoolean_acceptorMatchesWhenBothConditionsAreTrue() async throws { |
| 36 | + let output = GetWidgetOutput(booleanProperty: true, stringProperty: "match") |
| 37 | + let subject = try WaitersClient.orBooleanMatcherWaiterConfig().acceptors[0] |
| 38 | + let match = subject.evaluate(input: anInput, result: .success(output)) |
| 39 | + XCTAssertEqual(match, .success(.success(output))) |
| 40 | + } |
| 41 | + |
| 42 | + func test_orBoolean_acceptorDoesNotMatchWhenBothConditionsAreFalse() async throws { |
| 43 | + let output = GetWidgetOutput(booleanProperty: false, stringProperty: "no match") |
| 44 | + let subject = try WaitersClient.orBooleanMatcherWaiterConfig().acceptors[0] |
| 45 | + let match = subject.evaluate(input: anInput, result: .success(output)) |
| 46 | + XCTAssertNil(match) |
| 47 | + } |
| 48 | + |
| 49 | + func test_orBoolean_acceptorDoesNotMatchWhenBothPropertiesAreNil() async throws { |
| 50 | + let output = GetWidgetOutput(booleanProperty: nil, stringProperty: nil) |
| 51 | + let subject = try WaitersClient.orBooleanMatcherWaiterConfig().acceptors[0] |
| 52 | + let match = subject.evaluate(input: anInput, result: .success(output)) |
| 53 | + XCTAssertNil(match) |
| 54 | + } |
| 55 | +} |
0 commit comments