-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: add support for sub-expressions and list indexing in JMESPath #912
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,6 +193,50 @@ service WaitersTestService { | |
] | ||
}, | ||
|
||
// list indexing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Would be good to also test a more involved index expression like the struct list |
||
BooleanListIndexZeroEquals: { | ||
acceptors: [ | ||
{ | ||
state: "success", | ||
matcher: { | ||
output: { | ||
path: "lists.booleans[0]", | ||
expected: "true", | ||
comparator: "booleanEquals" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
BooleanListIndexOneEquals: { | ||
acceptors: [ | ||
{ | ||
state: "success", | ||
matcher: { | ||
output: { | ||
path: "lists.booleans[1]", | ||
expected: "true", | ||
comparator: "booleanEquals" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
TwoDimensionalBooleanListIndexZeroZeroEquals: { | ||
acceptors: [ | ||
{ | ||
state: "success", | ||
matcher: { | ||
output: { | ||
path: "twoDimensionalLists.booleansList[0][0]", | ||
expected: "true", | ||
comparator: "booleanEquals" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
// anyStringEquals | ||
StringListAnyStringEquals: { | ||
acceptors: [ | ||
|
@@ -764,6 +808,7 @@ structure GetEntityRequest { | |
structure GetEntityResponse { | ||
primitives: EntityPrimitives, | ||
lists: EntityLists, | ||
twoDimensionalLists: TwoDimensionalEntityLists, | ||
maps: EntityMaps, | ||
} | ||
|
||
|
@@ -800,6 +845,10 @@ structure EntityLists { | |
structs: StructList, | ||
} | ||
|
||
structure TwoDimensionalEntityLists { | ||
booleansList: TwoDimensionalBooleanList, | ||
} | ||
|
||
structure EntityMaps { | ||
booleans: BooleanMap, | ||
strings: StringMap, | ||
|
@@ -823,6 +872,10 @@ list BooleanList { | |
member: Boolean, | ||
} | ||
|
||
list TwoDimensionalBooleanList { | ||
member: BooleanList, | ||
} | ||
|
||
list StringList { | ||
member: String, | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,8 @@ import com.test.model.Enum | |
import com.test.waiters.* | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.* | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
class WaiterTest { | ||
|
@@ -107,6 +108,25 @@ class WaiterTest { | |
GetEntityResponse { primitives = EntityPrimitives { intEnum = IntEnum.One } }, | ||
) | ||
|
||
// list indexing | ||
@Test fun testBooleanListIndexZeroEquals() = successTest( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Would be good to have some failure tests (e.g. doesn't match, index out of bounds, etc). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smithy wouldn't allow out of bounds indexing but I tried. I would get an error message:
|
||
WaitersTestClient::waitUntilBooleanListIndexZeroEquals, | ||
GetEntityResponse { lists = EntityLists { booleans = listOf(false) } }, | ||
GetEntityResponse { lists = EntityLists { booleans = listOf(true) } }, | ||
) | ||
|
||
@Test fun testBooleanListIndexOneEquals() = successTest( | ||
WaitersTestClient::waitUntilBooleanListIndexOneEquals, | ||
GetEntityResponse { lists = EntityLists { booleans = listOf(false, false) } }, | ||
GetEntityResponse { lists = EntityLists { booleans = listOf(true, true) } }, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: This doesn't test that the correct index is being observed since both values in the list are changing at the same time. I recommend testing |
||
|
||
@Test fun testTwoDimensionalBooleanListIndexZeroZeroEquals() = successTest( | ||
WaitersTestClient::waitUntilTwoDimensionalBooleanListIndexZeroZeroEquals, | ||
GetEntityResponse { twoDimensionalLists = TwoDimensionalEntityLists { booleansList = listOf(listOf(false)) } }, | ||
GetEntityResponse { twoDimensionalLists = TwoDimensionalEntityLists { booleansList = listOf(listOf(true)) } }, | ||
) | ||
|
||
// anyStringEquals | ||
@Test fun testStringListAnyListStringEquals() = successTest( | ||
WaitersTestClient::waitUntilStringListAnyStringEquals, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
left
also be anIndexExpression
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it could but it really shouldn't be. The expression would be trying to access an index in nothing i.e. "[2]..."