Skip to content

Commit dadf763

Browse files
committed
Add E2E test
1 parent 9740446 commit dadf763

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
package aws.sdk.kotlin.services.route53
6+
7+
import aws.sdk.kotlin.services.route53.model.*
8+
import aws.smithy.kotlin.runtime.util.Uuid
9+
import kotlinx.coroutines.test.runTest
10+
import kotlin.test.Test
11+
import kotlin.test.assertContains
12+
import kotlin.test.assertNotNull
13+
import kotlin.test.assertFailsWith
14+
15+
// https://github.com/awslabs/aws-sdk-kotlin/issues/1433
16+
class InvalidChangeBatchTest {
17+
@Test
18+
fun testMessageIsPopulated() = runTest { Route53Client {}.use { client ->
19+
val createHostedZoneResp = client.createHostedZone {
20+
this.callerReference = Uuid.random().toString()
21+
this.name = "this-is-a-test-hosted-zone-for-aws-sdk-kotlin.com"
22+
}
23+
24+
val hostedZoneId = checkNotNull(createHostedZoneResp.hostedZone?.id) { "Hosted zone is unexpectedly null" }
25+
26+
val exception = assertFailsWith<InvalidChangeBatch> {
27+
client.changeResourceRecordSets {
28+
this.hostedZoneId = hostedZoneId
29+
this.changeBatch = ChangeBatch {
30+
this.changes = listOf(
31+
Change {
32+
this.action = ChangeAction.Delete
33+
this.resourceRecordSet = ResourceRecordSet {
34+
this.name = "test.blerg.com"
35+
this.type = RrType.Cname
36+
this.ttl = 300
37+
this.resourceRecords = listOf(
38+
ResourceRecord {
39+
value = "test.blerg.com"
40+
}
41+
)
42+
}
43+
},
44+
Change {
45+
this.action = ChangeAction.Create
46+
this.resourceRecordSet = ResourceRecordSet {
47+
this.name = "test.blerg.com"
48+
this.type = RrType.Cname
49+
this.ttl = 300
50+
this.resourceRecords = listOf(
51+
ResourceRecord {
52+
value = "test.blerg.com"
53+
}
54+
)
55+
}
56+
},
57+
)
58+
this.comment = "testing..."
59+
}
60+
}
61+
}
62+
63+
client.deleteHostedZone {
64+
id = hostedZoneId
65+
}
66+
67+
assertNotNull(exception.message)
68+
assertContains(exception.message, "[Tried to delete resource record set [name='test.blerg.com.', type='CNAME'] but it was not found, RRSet with DNS name test.blerg.com. is not permitted in zone this-is-a-test-domain-for-aws-sdk-kotlin.com., RRSet of type CNAME with DNS name test.blerg.com. is not permitted as it creates a CNAME loop in the zone.]")
69+
} }
70+
}

0 commit comments

Comments
 (0)