Skip to content

Commit 548e4e4

Browse files
committed
misc: test union with a member that has the same name
1 parent 98dd644 commit 548e4e4

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ include(":tests:e2e-test-util")
5959
include(":tests:codegen:smoke-tests")
6060
include(":tests:codegen:smoke-tests:services")
6161
include(":tests:codegen:checksums")
62+
include(":tests:codegen:union-example")
6263

6364
// generated services
6465
val File.isServiceDir: Boolean
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import aws.sdk.kotlin.gradle.codegen.dsl.smithyKotlinPlugin
2+
import aws.sdk.kotlin.gradle.codegen.smithyKotlinProjectionSrcDir
3+
import aws.sdk.kotlin.tests.codegen.CodegenTest
4+
import aws.sdk.kotlin.tests.codegen.Model
5+
6+
description = "AWS SDK for Kotlin's union codegen test suite"
7+
8+
val tests = listOf(
9+
CodegenTest("unions", Model("unions.smithy"), "aws.sdk.kotlin.test#TestService"),
10+
)
11+
12+
smithyBuild {
13+
this@Build_gradle.tests.forEach { test ->
14+
projections.register(test.name) {
15+
imports = listOf(layout.projectDirectory.file(test.model.path + test.model.fileName).asFile.absolutePath)
16+
smithyKotlinPlugin {
17+
serviceShapeId = test.serviceShapeId
18+
packageName = "aws.sdk.kotlin.test.${test.name.lowercase()}"
19+
packageVersion = "1.0"
20+
buildSettings {
21+
generateFullProject = false
22+
generateDefaultBuildFiles = false
23+
optInAnnotations = listOf(
24+
"aws.smithy.kotlin.runtime.InternalApi",
25+
"aws.sdk.kotlin.runtime.InternalSdkApi",
26+
)
27+
}
28+
}
29+
}
30+
}
31+
}
32+
33+
kotlin.sourceSets.getByName("test") {
34+
smithyBuild.projections.forEach {
35+
kotlin.srcDir(smithyBuild.smithyKotlinProjectionSrcDir(it.name))
36+
}
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package aws.sdk.kotlin.tests.codegen.unionexample
2+
3+
import aws.sdk.kotlin.test.unions.model.Foo
4+
import kotlin.test.Test
5+
6+
class UnionTest {
7+
@Test
8+
fun `try code generating a union with a member that has the same name as it, then use it`() {
9+
Foo.Foo(true).asFoo()
10+
}
11+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$version: "2"
2+
namespace aws.sdk.kotlin.test
3+
4+
use aws.protocols#awsJson1_0
5+
use smithy.rules#operationContextParams
6+
use smithy.rules#endpointRuleSet
7+
use aws.api#service
8+
9+
@awsJson1_0
10+
@service(sdkId: "UnionOperationTest")
11+
service TestService {
12+
operations: [DeleteObjects],
13+
version: "1"
14+
}
15+
16+
operation DeleteObjects {
17+
input: DeleteObjectsRequest
18+
}
19+
20+
structure DeleteObjectsRequest {
21+
Delete: Foo
22+
}
23+
24+
union Foo {
25+
foo: Boolean
26+
}

0 commit comments

Comments
 (0)