@@ -37,7 +37,7 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
3737 // Declare a Cosmos DB account
3838 offerType := documentdb .DatabaseAccountOfferType_Standard
3939 kind := documentdb .DatabaseAccount_Kind_Spec_GlobalDocumentDB
40- acct := documentdb.DatabaseAccount {
40+ acct := & documentdb.DatabaseAccount {
4141 ObjectMeta : tc .MakeObjectMetaWithName (tc .NoSpaceNamer .GenerateName ("sqlacct" )),
4242 Spec : documentdb.DatabaseAccount_Spec {
4343 Location : tc .AzureRegion ,
@@ -55,11 +55,11 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
5555
5656 // Declare a SQL database
5757 dbName := tc .Namer .GenerateName ("sqldb" )
58- db := documentdb.SqlDatabase {
58+ db := & documentdb.SqlDatabase {
5959 ObjectMeta : tc .MakeObjectMetaWithName (dbName ),
6060 Spec : documentdb.SqlDatabase_Spec {
6161 Location : to .Ptr ("australiaeast" ), // Capacity constraints // tc.AzureRegion
62- Owner : testcommon .AsOwner (& acct ),
62+ Owner : testcommon .AsOwner (acct ),
6363 Options : & documentdb.CreateUpdateOptions {
6464 AutoscaleSettings : & documentdb.AutoscaleSettings {
6565 MaxThroughput : to .Ptr (4000 ),
@@ -71,31 +71,43 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
7171 },
7272 }
7373 tc .LogSectionf ("Creating SQL account and database %q" , dbName )
74- tc .CreateResourcesAndWait (& acct , & db )
74+ tc .CreateResourcesAndWait (acct , db )
75+
76+ acctId := * acct .Status .Id
7577
7678 tc .T .Logf ("SQL account and database successfully created" )
7779 tc .RunParallelSubtests (
7880 testcommon.Subtest {
7981 Name : "CosmosDB SQL RoleAssignment CRUD" ,
8082 Test : func (tc * testcommon.KubePerTestContext ) {
81- CosmosDB_SQL_RoleAssignment_v20231115_CRUD (tc , rg , & acct )
83+ CosmosDB_SQL_RoleAssignment_v20231115_CRUD (tc , rg , acct )
8284 },
8385 },
8486 testcommon.Subtest {
8587 Name : "CosmosDB SQL Container CRUD" ,
8688 Test : func (tc * testcommon.KubePerTestContext ) {
87- CosmosDB_SQL_Container_v20231115_CRUD (tc , & db )
89+ CosmosDB_SQL_Container_v20231115_CRUD (tc , db )
8890 },
8991 },
9092 testcommon.Subtest {
9193 Name : "CosmosDB SQL Database throughputsettings CRUD" ,
9294 Test : func (tc * testcommon.KubePerTestContext ) {
93- CosmosDB_SQL_Database_ThroughputSettings_v20231115_CRUD (tc , & db )
95+ CosmosDB_SQL_Database_ThroughputSettings_v20231115_CRUD (tc , db )
9496 },
9597 })
9698
9799 // There aren't any attributes to update for databases, other than
98100 // throughput settings once they're available.
101+
102+ tc .DeleteResourceAndWait (acct )
103+
104+ // Ensure that the resource was really deleted in Azure
105+ exists , _ , err := tc .AzureClient .CheckExistenceWithGetByID (
106+ tc .Ctx ,
107+ acctId ,
108+ string (documentdb .APIVersion_Value ))
109+ tc .Expect (err ).ToNot (HaveOccurred ())
110+ tc .Expect (exists ).To (BeFalse ())
99111}
100112
101113func CosmosDB_SQL_Container_v20231115_CRUD (tc * testcommon.KubePerTestContext , db client.Object ) {
@@ -106,7 +118,7 @@ func CosmosDB_SQL_Container_v20231115_CRUD(tc *testcommon.KubePerTestContext, db
106118 lastWriterWins := documentdb .ConflictResolutionPolicy_Mode_LastWriterWins
107119 consistent := documentdb .IndexingPolicy_IndexingMode_Consistent
108120 hash := documentdb .ContainerPartitionKey_Kind_Hash
109- container := documentdb.SqlDatabaseContainer {
121+ container := & documentdb.SqlDatabaseContainer {
110122 ObjectMeta : tc .MakeObjectMetaWithName (name ),
111123 Spec : documentdb.SqlDatabaseContainer_Spec {
112124 Location : to .Ptr ("australiaeast" ), // Capacity constraints // tc.AzureRegion
@@ -137,37 +149,38 @@ func CosmosDB_SQL_Container_v20231115_CRUD(tc *testcommon.KubePerTestContext, db
137149 },
138150 }
139151
140- tc .CreateResourceAndWait (& container )
152+ tc .CreateResourceAndWait (container )
153+
141154 tc .RunParallelSubtests (
142155 testcommon.Subtest {
143156 Name : "CosmosDB SQL Trigger CRUD" ,
144157 Test : func (tc * testcommon.KubePerTestContext ) {
145- CosmosDB_SQL_Trigger_v20231115_CRUD (tc , & container )
158+ CosmosDB_SQL_Trigger_v20231115_CRUD (tc , container )
146159 },
147160 },
148161 testcommon.Subtest {
149162 Name : "CosmosDB SQL Stored Procedure CRUD" ,
150163 Test : func (tc * testcommon.KubePerTestContext ) {
151- CosmosDB_SQL_StoredProcedure_v20231115_CRUD (tc , & container )
164+ CosmosDB_SQL_StoredProcedure_v20231115_CRUD (tc , container )
152165 },
153166 },
154167 testcommon.Subtest {
155168 Name : "CosmosDB SQL User-defined Function CRUD" ,
156169 Test : func (tc * testcommon.KubePerTestContext ) {
157- CosmosDB_SQL_UserDefinedFunction_v20231115_CRUD (tc , & container )
170+ CosmosDB_SQL_UserDefinedFunction_v20231115_CRUD (tc , container )
158171 },
159172 },
160173 testcommon.Subtest {
161174 Name : "CosmosDB SQL Container ThroughputSettings CRUD" ,
162175 Test : func (tc * testcommon.KubePerTestContext ) {
163- CosmosDB_SQL_Database_Container_ThroughputSettings_v20231115_CRUD (tc , & container )
176+ CosmosDB_SQL_Database_Container_ThroughputSettings_v20231115_CRUD (tc , container )
164177 },
165178 })
166179
167180 tc .LogSubsectionf ("Updating the default TTL on container %q" , name )
168181 old := container .DeepCopy ()
169182 container .Spec .Resource .DefaultTtl = to .Ptr (400 )
170- tc .PatchResourceAndWait (old , & container )
183+ tc .PatchResourceAndWait (old , container )
171184 tc .Expect (container .Status .Resource ).ToNot (BeNil ())
172185 tc .Expect (container .Status .Resource .DefaultTtl ).ToNot (BeNil ())
173186 tc .Expect (* container .Status .Resource .DefaultTtl ).To (Equal (400 ))
0 commit comments