forked from talariadb/talaria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure_test.go
38 lines (30 loc) · 1023 Bytes
/
azure_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package azure
import (
"os"
"strings"
"testing"
"github.com/kelindar/talaria/internal/monitor"
"github.com/kelindar/talaria/internal/monitor/logging"
"github.com/kelindar/talaria/internal/monitor/statsd"
"github.com/stretchr/testify/assert"
)
func TestWriter(t *testing.T) {
os.Setenv("AZURE_STORAGE_ACCOUNT", "golangrocksonazure")
os.Setenv("AZURE_STORAGE_ACCESS_KEY", "YmFy")
c, err := New("test", "test")
assert.NotNil(t, c)
assert.NoError(t, err)
assert.NotPanics(t, func() {
err := c.Write([]byte("abc"), []byte("hello"))
assert.NotNil(t, err)
})
}
func TestMultiAccountWriter(t *testing.T) {
os.Setenv("AZURE_TENANT_ID", "xyz")
os.Setenv("AZURE_CLIENT_ID", "xyz")
os.Setenv("AZURE_CLIENT_SECRET", "xyz")
c, err := NewMultiAccountWriter(monitor.New(logging.NewStandard(), statsd.NewNoop(), "x", "x"),
defaultBlobServiceURL, "container", "x", []string{"x-0"}, nil, 0, 0)
assert.Nil(t, c)
assert.True(t, strings.Contains(err.Error(), "azure: unable to get azure storage credential"))
}