mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-20 09:20:11 +00:00
Extract constants instead of duplicating literals
This commit is contained in:
@@ -19,7 +19,7 @@ func Test_Authentication(t *testing.T) {
|
||||
t.Run("Should get 200 when correct account key is used", func(t *testing.T) {
|
||||
ts.DataStore.DeleteDatabase(testDatabaseName)
|
||||
client, err := azcosmos.NewClientFromConnectionString(
|
||||
fmt.Sprintf("AccountEndpoint=%s;AccountKey=%s", ts.URL, config.DefaultAccountKey),
|
||||
formatConnectionString(ts.URL, config.DefaultAccountKey),
|
||||
&azcosmos.ClientOptions{},
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
@@ -35,7 +35,7 @@ func Test_Authentication(t *testing.T) {
|
||||
t.Run("Should get 401 when wrong account key is used", func(t *testing.T) {
|
||||
ts.DataStore.DeleteDatabase(testDatabaseName)
|
||||
client, err := azcosmos.NewClientFromConnectionString(
|
||||
fmt.Sprintf("AccountEndpoint=%s;AccountKey=%s", ts.URL, "AAAA"),
|
||||
formatConnectionString(ts.URL, "AAAA"),
|
||||
&azcosmos.ClientOptions{},
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
@@ -72,7 +72,7 @@ func Test_Authentication_Disabled(t *testing.T) {
|
||||
t.Run("Should get 200 when wrong account key is used, but authentication is dissabled", func(t *testing.T) {
|
||||
ts.DataStore.DeleteDatabase(testDatabaseName)
|
||||
client, err := azcosmos.NewClientFromConnectionString(
|
||||
fmt.Sprintf("AccountEndpoint=%s;AccountKey=%s", ts.URL, "AAAA"),
|
||||
formatConnectionString(ts.URL, "AAAA"),
|
||||
&azcosmos.ClientOptions{},
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
@@ -85,3 +85,7 @@ func Test_Authentication_Disabled(t *testing.T) {
|
||||
assert.Equal(t, createResponse.DatabaseProperties.ID, testDatabaseName)
|
||||
})
|
||||
}
|
||||
|
||||
func formatConnectionString(endpoint, key string) string {
|
||||
return fmt.Sprintf("AccountEndpoint=%s;AccountKey=%s", endpoint, key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user