@@ -37,7 +37,7 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
37
37
// Declare a Cosmos DB account
38
38
offerType := documentdb .DatabaseAccountOfferType_Standard
39
39
kind := documentdb .DatabaseAccount_Kind_Spec_GlobalDocumentDB
40
- acct := documentdb.DatabaseAccount {
40
+ acct := & documentdb.DatabaseAccount {
41
41
ObjectMeta : tc .MakeObjectMetaWithName (tc .NoSpaceNamer .GenerateName ("sqlacct" )),
42
42
Spec : documentdb.DatabaseAccount_Spec {
43
43
Location : tc .AzureRegion ,
@@ -55,11 +55,11 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
55
55
56
56
// Declare a SQL database
57
57
dbName := tc .Namer .GenerateName ("sqldb" )
58
- db := documentdb.SqlDatabase {
58
+ db := & documentdb.SqlDatabase {
59
59
ObjectMeta : tc .MakeObjectMetaWithName (dbName ),
60
60
Spec : documentdb.SqlDatabase_Spec {
61
61
Location : to .Ptr ("australiaeast" ), // Capacity constraints // tc.AzureRegion
62
- Owner : testcommon .AsOwner (& acct ),
62
+ Owner : testcommon .AsOwner (acct ),
63
63
Options : & documentdb.CreateUpdateOptions {
64
64
AutoscaleSettings : & documentdb.AutoscaleSettings {
65
65
MaxThroughput : to .Ptr (4000 ),
@@ -71,31 +71,43 @@ func Test_DocumentDB_SQLDatabase_v20231115_CRUD(t *testing.T) {
71
71
},
72
72
}
73
73
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
75
77
76
78
tc .T .Logf ("SQL account and database successfully created" )
77
79
tc .RunParallelSubtests (
78
80
testcommon.Subtest {
79
81
Name : "CosmosDB SQL RoleAssignment CRUD" ,
80
82
Test : func (tc * testcommon.KubePerTestContext ) {
81
- CosmosDB_SQL_RoleAssignment_v20231115_CRUD (tc , rg , & acct )
83
+ CosmosDB_SQL_RoleAssignment_v20231115_CRUD (tc , rg , acct )
82
84
},
83
85
},
84
86
testcommon.Subtest {
85
87
Name : "CosmosDB SQL Container CRUD" ,
86
88
Test : func (tc * testcommon.KubePerTestContext ) {
87
- CosmosDB_SQL_Container_v20231115_CRUD (tc , & db )
89
+ CosmosDB_SQL_Container_v20231115_CRUD (tc , db )
88
90
},
89
91
},
90
92
testcommon.Subtest {
91
93
Name : "CosmosDB SQL Database throughputsettings CRUD" ,
92
94
Test : func (tc * testcommon.KubePerTestContext ) {
93
- CosmosDB_SQL_Database_ThroughputSettings_v20231115_CRUD (tc , & db )
95
+ CosmosDB_SQL_Database_ThroughputSettings_v20231115_CRUD (tc , db )
94
96
},
95
97
})
96
98
97
99
// There aren't any attributes to update for databases, other than
98
100
// 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 ())
99
111
}
100
112
101
113
func 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
106
118
lastWriterWins := documentdb .ConflictResolutionPolicy_Mode_LastWriterWins
107
119
consistent := documentdb .IndexingPolicy_IndexingMode_Consistent
108
120
hash := documentdb .ContainerPartitionKey_Kind_Hash
109
- container := documentdb.SqlDatabaseContainer {
121
+ container := & documentdb.SqlDatabaseContainer {
110
122
ObjectMeta : tc .MakeObjectMetaWithName (name ),
111
123
Spec : documentdb.SqlDatabaseContainer_Spec {
112
124
Location : to .Ptr ("australiaeast" ), // Capacity constraints // tc.AzureRegion
@@ -137,37 +149,38 @@ func CosmosDB_SQL_Container_v20231115_CRUD(tc *testcommon.KubePerTestContext, db
137
149
},
138
150
}
139
151
140
- tc .CreateResourceAndWait (& container )
152
+ tc .CreateResourceAndWait (container )
153
+
141
154
tc .RunParallelSubtests (
142
155
testcommon.Subtest {
143
156
Name : "CosmosDB SQL Trigger CRUD" ,
144
157
Test : func (tc * testcommon.KubePerTestContext ) {
145
- CosmosDB_SQL_Trigger_v20231115_CRUD (tc , & container )
158
+ CosmosDB_SQL_Trigger_v20231115_CRUD (tc , container )
146
159
},
147
160
},
148
161
testcommon.Subtest {
149
162
Name : "CosmosDB SQL Stored Procedure CRUD" ,
150
163
Test : func (tc * testcommon.KubePerTestContext ) {
151
- CosmosDB_SQL_StoredProcedure_v20231115_CRUD (tc , & container )
164
+ CosmosDB_SQL_StoredProcedure_v20231115_CRUD (tc , container )
152
165
},
153
166
},
154
167
testcommon.Subtest {
155
168
Name : "CosmosDB SQL User-defined Function CRUD" ,
156
169
Test : func (tc * testcommon.KubePerTestContext ) {
157
- CosmosDB_SQL_UserDefinedFunction_v20231115_CRUD (tc , & container )
170
+ CosmosDB_SQL_UserDefinedFunction_v20231115_CRUD (tc , container )
158
171
},
159
172
},
160
173
testcommon.Subtest {
161
174
Name : "CosmosDB SQL Container ThroughputSettings CRUD" ,
162
175
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 )
164
177
},
165
178
})
166
179
167
180
tc .LogSubsectionf ("Updating the default TTL on container %q" , name )
168
181
old := container .DeepCopy ()
169
182
container .Spec .Resource .DefaultTtl = to .Ptr (400 )
170
- tc .PatchResourceAndWait (old , & container )
183
+ tc .PatchResourceAndWait (old , container )
171
184
tc .Expect (container .Status .Resource ).ToNot (BeNil ())
172
185
tc .Expect (container .Status .Resource .DefaultTtl ).ToNot (BeNil ())
173
186
tc .Expect (* container .Status .Resource .DefaultTtl ).To (Equal (400 ))
0 commit comments