Skip to content

Commit ddd034c

Browse files
authored
Add tests for OrExpression JMESPath (#2088)
1 parent 3b469af commit ddd034c

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}

codegen/protocol-test-codegen-local/model/waiters.smithy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ service Waiters {
232232
}
233233
]
234234
}
235+
OrBooleanMatcher: {
236+
documentation: "Matches when booleanProperty is true OR stringProperty equals 'match'"
237+
acceptors: [
238+
{
239+
state: "success"
240+
matcher: {
241+
output: {
242+
path: "booleanProperty == `true` || stringProperty == 'match'"
243+
expected: "true"
244+
comparator: "booleanEquals"
245+
}
246+
}
247+
}
248+
]
249+
}
235250
)
236251
operation GetWidget {
237252
input: WidgetInput,

0 commit comments

Comments
 (0)