-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add azure_helpers_test.go with getStorageAccount{Name,Key} tests
- Loading branch information
1 parent
3e2383a
commit 33ebaef
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package azure | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana/dskit/flagext" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
const ( | ||
TestStorageAccountName = "foobar" | ||
TestStorageAccountKey = "abc123" | ||
) | ||
|
||
// TestGetStorageAccountName* explicitly broken out into | ||
// separate tests instead of table-driven due to usage of t.SetEnv | ||
func TestGetStorageAccountNameInConfig(t *testing.T) { | ||
cfg := Config{StorageAccountName: TestStorageAccountName} | ||
|
||
actual := getStorageAccountName(&cfg) | ||
assert.Equal(t, TestStorageAccountName, actual) | ||
} | ||
|
||
func TestGetStorageAccountNameInEnv(t *testing.T) { | ||
cfg := Config{} | ||
t.Setenv("AZURE_STORAGE_ACCOUNT", TestStorageAccountName) | ||
|
||
actual := getStorageAccountName(&cfg) | ||
assert.Equal(t, TestStorageAccountName, actual) | ||
} | ||
|
||
func TestGetStorageAccountNameNotSet(t *testing.T) { | ||
cfg := Config{} | ||
|
||
actual := getStorageAccountName(&cfg) | ||
assert.Equal(t, "", actual) | ||
} | ||
|
||
// TestGetStorageAccountKey* explicitly broken out into | ||
// separate tests instead of table-driven due to usage of t.SetEnv | ||
func TestGetStorageAccountKeyInConfig(t *testing.T) { | ||
storageAccountKeySecret := flagext.SecretWithValue(TestStorageAccountKey) | ||
cfg := Config{StorageAccountKey: storageAccountKeySecret} | ||
|
||
actual := getStorageAccountKey(&cfg) | ||
assert.Equal(t, TestStorageAccountKey, actual) | ||
} | ||
|
||
func TestGetStorageAccountKeyInEnv(t *testing.T) { | ||
cfg := Config{} | ||
t.Setenv("AZURE_STORAGE_KEY", TestStorageAccountKey) | ||
|
||
actual := getStorageAccountKey(&cfg) | ||
assert.Equal(t, TestStorageAccountKey, actual) | ||
} | ||
|
||
func TestGetStorageAccountKeyNotSet(t *testing.T) { | ||
cfg := Config{} | ||
|
||
actual := getStorageAccountKey(&cfg) | ||
assert.Equal(t, "", actual) | ||
} |