Skip to content

Commit

Permalink
chore: update protocol tests (#3913)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Oct 7, 2021
1 parent 3b21fb4 commit f017a84
Show file tree
Hide file tree
Showing 8 changed files with 939 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/feature-protocol-2b945450.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "protocol",
"description": "Update protocol tests"
}
143 changes: 143 additions & 0 deletions test/fixtures/protocol/input/rest-json.json
Original file line number Diff line number Diff line change
Expand Up @@ -1620,5 +1620,148 @@
}
}
]
},
{
"description": "Union trait",
"metadata": {
"protocol": "rest-json",
"apiVersion": "2014-01-01"
},
"shapes": {
"InputShape": {
"type": "structure",
"members": {
"OneOf": {"shape": "MyUnion"}
}
},
"MyUnion": {
"type": "structure",
"union": true,
"members": {
"a": {"shape": "StringType"},
"b": {"shape": "StringType"},
"c": {"shape": "Struct"},
"d": {"shape": "Struct"},
"e": {"shape": "ComplexList"}
}
},
"StringType": {
"type": "string"
},
"Struct": {
"type": "structure",
"members": {
"hello": {"shape": "StringType"}
}
},
"ComplexList": {
"type": "list",
"member": {"shape": "Struct"}
}
},
"cases": [
{
"given": {
"input": {
"shape": "InputShape"
},
"http": {
"method": "POST"
},
"name": "OperationName"
},
"params": {
"OneOf": {"a": "hi"}
},
"serialized": {
"uri": "/",
"body": "{\"OneOf\": {\"a\": \"hi\"}}"
}
},
{
"given": {
"input": {
"shape": "InputShape"
},
"http": {
"method": "POST"
},
"name": "OperationName"
},
"params": {
"OneOf": {"b": "hi"}
},
"serialized": {
"uri": "/",
"body": "{\"OneOf\": {\"b\": \"hi\"}}"
}
},
{
"given": {
"input": {
"shape": "InputShape"
},
"http": {
"method": "POST"
},
"name": "OperationName"
},
"params": {
"OneOf": {
"c": {
"hello": "hi"
}
}
},
"serialized": {
"uri": "/",
"body": "{\"OneOf\": {\"c\": {\"hello\": \"hi\"}}}"
}
},
{
"given": {
"input": {
"shape": "InputShape"
},
"http": {
"method": "POST"
},
"name": "OperationName"
},
"params": {
"OneOf": {
"d": {
"hello": "hi"
}
}
},
"serialized": {
"uri": "/",
"body": "{\"OneOf\": {\"d\": {\"hello\": \"hi\"}}}"
}
},
{
"given": {
"input": {
"shape": "InputShape"
},
"http": {
"method": "POST"
},
"name": "OperationName"
},
"params": {
"OneOf": {
"e": [
{"hello": "hi"}
]
}
},
"serialized": {
"uri": "/",
"body": "{\"OneOf\": {\"e\": [{\"hello\": \"hi\"}]}}"
}
}
]
}
]
87 changes: 87 additions & 0 deletions test/fixtures/protocol/output/ec2.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,5 +567,92 @@
}
}
]
},
{
"description": "Modeled exceptions",
"metadata": {
"protocol": "ec2"
},
"shapes": {
"ExceptionShape": {
"type": "structure",
"members": {
"Status": {
"shape": "StatusShape",
"location": "statusCode"
},
"BodyMember": {
"shape": "StringType"
},
"Message": {
"shape": "StringType"
}
}
},
"OtherExceptionShape": {
"BodyMember": {
"shape": "StringType"
}
},
"StatusShape": {
"type": "integer"
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"errors": [
{"shape": "ExceptionShape"}
],
"name": "OperationName"
},
"error": {
"Status": 400,
"BodyMember": "mybody",
"Message": "mymessage"
},
"errorCode": "ExceptionShape",
"errorMessage": "mymessage",
"response": {
"status_code": 400,
"headers": {},
"body": "<Response><Errors><Error><Code>ExceptionShape</Code><Message>mymessage</Message><BodyMember>mybody</BodyMember></Error></Errors></Response>"
}
},
{
"given": {
"errors": [
{"shape": "ExceptionShape"}
],
"name": "OperationName"
},
"error": {},
"errorCode": "OtherExceptionShape",
"errorMessage": "mymessage",
"response": {
"status_code": 400,
"headers": {},
"body": "<Response><Errors><Error><Code>OtherExceptionShape</Code><Message>mymessage</Message><BodyMember>mybody</BodyMember></Error></Errors></Response>"
}
},
{
"given": {
"errors": [
{"shape": "ExceptionShape"}
],
"name": "OperationName"
},
"error": {},
"errorCode": "UndefinedShape",
"response": {
"status_code": 400,
"headers": {},
"body": "<Response><Errors><Error><Code>UndefinedShape</Code><BodyMember>mybody</BodyMember></Error></Errors></Response>"
}
}
]
}
]
Loading

0 comments on commit f017a84

Please sign in to comment.