Skip to content

Commit 57e4409

Browse files
authored
chore: read service specific tests into model (#295)
1 parent faca074 commit 57e4409

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
$version: "1.0"
2+
3+
namespace com.amazonaws.s3
4+
use smithy.test#httpResponseTests
5+
use smithy.test#httpRequestTests
6+
7+
apply NotFound @httpResponseTests([
8+
{
9+
id: "HeadObjectEmptyBody",
10+
documentation: "This test case validates https://github.com/awslabs/aws-sdk-swift/issues/183",
11+
params: {
12+
},
13+
body: "",
14+
protocol: "aws.protocols#restXml",
15+
code: 404,
16+
headers: {
17+
"x-amz-request-id": "GRZ6BZ468DF52F2E",
18+
"x-amz-id-2": "UTniwu6QmCIjVeuK2ZfeWBOnu7SqMQOS3Vac6B/K4H2ZCawYUl+nDbhGTImuyhZ5DFiojR3Kcz4=",
19+
"content-type": "application/xml",
20+
"date": "Thu, 03 Jun 2021 04:05:52 GMT",
21+
"server": "AmazonS3"
22+
}
23+
}
24+
])
25+
26+
// FIXME - when we implement virtual host addressing as the default will need to change the host and uri
27+
// see: https://github.com/awslabs/aws-sdk-kotlin/issues/220
28+
apply PutObject @httpRequestTests([
29+
{
30+
id: "PutObjectDefaultContentType",
31+
documentation: "This test case validates default content-type behavior when not specified in the request",
32+
protocol: "aws.protocols#restXml",
33+
method: "PUT",
34+
uri: "/mybucket/mykey",
35+
host: "s3.us-west-2.amazonaws.com",
36+
body: "foobar",
37+
bodyMediaType: "application/octet-stream",
38+
headers: {
39+
"Content-Type": "application/octet-stream"
40+
},
41+
params: {
42+
Bucket: "mybucket",
43+
Key: "mykey",
44+
Body: "foobar"
45+
}
46+
},
47+
{
48+
id: "PutOtTbjectExplicitContenype",
49+
documentation: "This test case validates https://github.com/awslabs/aws-sdk-kotlin/issues/193",
50+
protocol: "aws.protocols#restXml",
51+
method: "PUT",
52+
uri: "/mybucket/mykey",
53+
host: "s3.us-west-2.amazonaws.com",
54+
body: "{\"foo\":\"bar\"}",
55+
headers: {
56+
"Content-Type": "application/json"
57+
},
58+
params: {
59+
Bucket: "mybucket",
60+
Key: "mykey",
61+
ContentType: "application/json",
62+
Body: "{\"foo\":\"bar\"}"
63+
}
64+
}
65+
])

codegen/sdk-codegen/build.gradle.kts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,21 @@ data class AwsService(
7878
// The generated smithy-build.json file is not committed to git since
7979
// it's rebuilt each time codegen is performed.
8080
fun generateSmithyBuild(services: List<AwsService>): String {
81+
require(services.isNotEmpty()) {
82+
"No services discovered. Verify aws.services and aws.protocols properties in local.build. Aborting."
83+
}
8184
val buildStandaloneSdk = getProperty("buildStandaloneSdk")?.toBoolean() ?: false
8285
val projections = services.joinToString(",") { service ->
8386
// escape windows paths for valid json
8487
val absModelPath = service.modelFile.absolutePath.replace("\\", "\\\\")
88+
val importPaths = mutableListOf(absModelPath)
89+
if (file(service.modelExtrasDir).exists()) {
90+
importPaths.add(service.modelExtrasDir.replace("\\", "\\\\"))
91+
}
92+
val imports = importPaths.joinToString { "\"$it\"" }
8593
"""
8694
"${service.projectionName}": {
87-
"imports": ["$absModelPath"],
95+
"imports": [$imports],
8896
"plugins": {
8997
"swift-codegen": {
9098
"service": "${service.name}",
@@ -168,6 +176,12 @@ val AwsService.destinationDir: String
168176
return rootProject.file("release").absolutePath
169177
}
170178

179+
val AwsService.modelExtrasDir: String
180+
get() {
181+
val sanitizedName = projectionName.split(".")[0]
182+
return rootProject.file("codegen/sdk-codegen/aws-models-test/${sanitizedName}").absolutePath
183+
}
184+
171185
task("stageSdks") {
172186
group = "codegen"
173187
description = "relocate generated SDK(s) from build directory to release dir"

0 commit comments

Comments
 (0)