Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit 4c698b4

Browse files
Add CosmosDB Resource Identifier (#667)
Co-authored-by: Joel Hendrix <jhendrix@microsoft.com>
1 parent 8c4109c commit 4c698b4

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

autorest/azure/environments.go

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type ResourceIdentifier struct {
5050
Synapse string `json:"synapse"`
5151
ServiceBus string `json:"serviceBus"`
5252
SQLDatabase string `json:"sqlDatabase"`
53+
CosmosDB string `json:"cosmosDB"`
5354
}
5455

5556
// Environment represents a set of endpoints for each of Azure's Clouds.
@@ -123,6 +124,7 @@ var (
123124
Synapse: "https://dev.azuresynapse.net",
124125
ServiceBus: "https://servicebus.azure.net/",
125126
SQLDatabase: "https://database.windows.net/",
127+
CosmosDB: "https://cosmos.azure.com",
126128
},
127129
}
128130

@@ -165,6 +167,7 @@ var (
165167
Synapse: NotAvailable,
166168
ServiceBus: "https://servicebus.azure.net/",
167169
SQLDatabase: "https://database.usgovcloudapi.net/",
170+
CosmosDB: "https://cosmos.azure.com",
168171
},
169172
}
170173

@@ -207,6 +210,7 @@ var (
207210
Synapse: "https://dev.azuresynapse.net",
208211
ServiceBus: "https://servicebus.azure.net/",
209212
SQLDatabase: "https://database.chinacloudapi.cn/",
213+
CosmosDB: "https://cosmos.azure.com",
210214
},
211215
}
212216

@@ -249,6 +253,7 @@ var (
249253
Synapse: NotAvailable,
250254
ServiceBus: "https://servicebus.azure.net/",
251255
SQLDatabase: "https://database.cloudapi.de/",
256+
CosmosDB: "https://cosmos.azure.com",
252257
},
253258
}
254259
)

autorest/azure/environments_test.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
keyvaultResourceID = "--keyvault-resource-id--"
3535
opInsightsResourceID = "--operational-insights-resource-id--"
3636
ossRDBMSResourceID = "--oss-rdbms-resource-id--"
37+
cosmosDBResourceID = "--cosmosdb-resource-id--"
3738
)
3839

3940
// This correlates to the expected contents of ./testdata/test_environment_1.json
@@ -67,6 +68,7 @@ var testEnvironment1 = Environment{
6768
KeyVault: keyvaultResourceID,
6869
OperationalInsights: opInsightsResourceID,
6970
OSSRDBMS: ossRDBMSResourceID,
71+
CosmosDB: cosmosDBResourceID,
7072
},
7173
}
7274

@@ -79,7 +81,6 @@ func TestEnvironment_EnvironmentFromURL_NoOverride_Success(t *testing.T) {
7981
defer ts.Close()
8082

8183
got, err := EnvironmentFromURL(ts.URL)
82-
8384
if err != nil {
8485
t.Error(err)
8586
}
@@ -101,7 +102,6 @@ func TestEnvironment_EnvironmentFromURL_OverrideStorageSuffix_Success(t *testing
101102
Value: "fakeStorageSuffix",
102103
}
103104
got, err := EnvironmentFromURL(ts.URL, overrideProperty)
104-
105105
if err != nil {
106106
t.Error(err)
107107
}
@@ -228,7 +228,8 @@ func TestDeserializeEnvironment(t *testing.T) {
228228
"graph": "` + graphResourceID + `",
229229
"keyVault": "` + keyvaultResourceID + `",
230230
"operationalInsights": "` + opInsightsResourceID + `",
231-
"ossRDBMS": "` + ossRDBMSResourceID + `"
231+
"ossRDBMS": "` + ossRDBMSResourceID + `",
232+
"cosmosDB": "` + cosmosDBResourceID + `"
232233
}
233234
}`
234235

@@ -319,6 +320,9 @@ func TestDeserializeEnvironment(t *testing.T) {
319320
if ossRDBMSResourceID != testSubject.ResourceIdentifiers.OSSRDBMS {
320321
t.Errorf("Expected ResourceIdentifiers.OperationalInsights to be "+ossRDBMSResourceID+", but got %q", testSubject.ResourceIdentifiers.OSSRDBMS)
321322
}
323+
if cosmosDBResourceID != testSubject.ResourceIdentifiers.CosmosDB {
324+
t.Errorf("Expected ResourceIdentifiers.CosmosDB to be "+cosmosDBResourceID+", but got %q", testSubject.ResourceIdentifiers.CosmosDB)
325+
}
322326
}
323327

324328
func TestRoundTripSerialization(t *testing.T) {
@@ -352,6 +356,7 @@ func TestRoundTripSerialization(t *testing.T) {
352356
KeyVault: keyvaultResourceID,
353357
OperationalInsights: opInsightsResourceID,
354358
OSSRDBMS: ossRDBMSResourceID,
359+
CosmosDB: cosmosDBResourceID,
355360
},
356361
}
357362

@@ -450,6 +455,9 @@ func TestRoundTripSerialization(t *testing.T) {
450455
if env.ResourceIdentifiers.OSSRDBMS != testSubject.ResourceIdentifiers.OSSRDBMS {
451456
t.Errorf("Expected ResourceIdentifiers.OSSRDBMS to be %q, but got %q", env.ResourceIdentifiers.OSSRDBMS, testSubject.ResourceIdentifiers.OSSRDBMS)
452457
}
458+
if env.ResourceIdentifiers.CosmosDB != testSubject.ResourceIdentifiers.CosmosDB {
459+
t.Errorf("Expected ResourceIdentifiers.CosmosDB to be %q, but got %q", env.ResourceIdentifiers.CosmosDB, testSubject.ResourceIdentifiers.CosmosDB)
460+
}
453461
}
454462

455463
func TestSetEnvironment(t *testing.T) {

autorest/azure/testdata/test_environment_1.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"graph": "--graph-resource-id--",
2828
"keyVault": "--keyvault-resource-id--",
2929
"operationalInsights": "--operational-insights-resource-id--",
30-
"ossRDBMS": "--oss-rdbms-resource-id--"
30+
"ossRDBMS": "--oss-rdbms-resource-id--",
31+
"cosmosDB": "--cosmosdb-resource-id--"
3132
}
3233
}

0 commit comments

Comments
 (0)