-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathazure_test.go
68 lines (56 loc) · 1.8 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package azure
import (
"bytes"
"os"
"strings"
"testing"
eorc "github.com/crphang/orc"
"github.com/kelindar/talaria/internal/encoding/block"
"github.com/kelindar/talaria/internal/encoding/orc"
"github.com/kelindar/talaria/internal/encoding/typeof"
"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"
)
// Create a base block for testing purpose
func blockBase() ([]block.Block, error) {
schema := typeof.Schema{
"col0": typeof.String,
"col1": typeof.Int64,
"col2": typeof.Float64,
}
orcSchema, _ := orc.SchemaFor(schema)
orcBuffer1 := &bytes.Buffer{}
writer, _ := eorc.NewWriter(orcBuffer1,
eorc.SetSchema(orcSchema))
_ = writer.Write("eventName", 1, 1.0)
_ = writer.Close()
apply := block.Transform(nil)
block, err := block.FromOrcBy(orcBuffer1.Bytes(), "col0", nil, apply)
if err != nil {
return nil, err
}
return block, nil
}
func TestWriter(t *testing.T) {
os.Setenv("AZURE_STORAGE_ACCOUNT", "golangrocksonazure")
os.Setenv("AZURE_STORAGE_ACCESS_KEY", "YmFy")
c, err := New("test", "test", "", "orc", nil)
assert.NotNil(t, c)
assert.NoError(t, err)
b, err := blockBase()
assert.Nil(t, err)
assert.NotPanics(t, func() {
err := c.Write([]byte("abc"), b)
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"), "", "orc", defaultBlobServiceURL, "container", "x", []string{"x-0"}, []uint{0}, 0, 0)
assert.Nil(t, c)
assert.True(t, strings.Contains(err.Error(), "azure: unable to get azure storage credential"))
}