-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathstore_test.go
More file actions
88 lines (74 loc) · 2.09 KB
/
Copy pathstore_test.go
File metadata and controls
88 lines (74 loc) · 2.09 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package azure_test
import (
"os"
"testing"
"github.com/araddon/gou"
"github.com/stretchr/testify/assert"
"github.com/dvriesman/cloudstorage"
"github.com/dvriesman/cloudstorage/azure"
"github.com/dvriesman/cloudstorage/testutils"
)
/*
# to use azure tests ensure you have exported
export AZURE_KEY="aaa"
export AZURE_PROJECT="bbb"
export AZURE_BUCKET="cloudstorageunittests"
*/
var config = &cloudstorage.Config{
Type: azure.StoreType,
AuthMethod: azure.AuthKey,
Bucket: os.Getenv("AZURE_BUCKET"),
TmpDir: "/tmp/localcache/azure",
Settings: make(gou.JsonHelper),
}
func TestConfig(t *testing.T) {
if config.Bucket == "" {
t.Logf("must provide AZURE_PROJECT, AZURE_KEY, AZURE_PROJECT env vars")
t.Skip()
return
}
conf := &cloudstorage.Config{
Type: azure.StoreType,
Project: os.Getenv("AZURE_PROJECT"),
Settings: make(gou.JsonHelper),
}
// Should error with empty config
_, err := cloudstorage.NewStore(conf)
assert.NotEqual(t, nil, err)
conf.AuthMethod = azure.AuthKey
conf.Settings[azure.ConfKeyAuthKey] = ""
_, err = cloudstorage.NewStore(conf)
assert.NotEqual(t, nil, err)
conf.Settings[azure.ConfKeyAuthKey] = "bad"
_, err = cloudstorage.NewStore(conf)
assert.NotEqual(t, nil, err)
conf.Settings[azure.ConfKeyAuthKey] = os.Getenv("AZURE_KEY")
client, sess, err := azure.NewClient(conf)
assert.Equal(t, nil, err)
assert.NotEqual(t, nil, client)
conf.TmpDir = ""
_, err = azure.NewStore(client, sess, conf)
assert.NotEqual(t, nil, err)
// Trying to find dir they don't have access to?
conf.TmpDir = "/home/fake"
_, err = cloudstorage.NewStore(conf)
assert.NotEqual(t, nil, err)
}
func TestAll(t *testing.T) {
config.Project = os.Getenv("AZURE_PROJECT")
if config.Project == "" {
t.Logf("must provide AZURE_PROJECT")
t.Skip()
return
}
config.Settings[azure.ConfKeyAuthKey] = os.Getenv("AZURE_KEY")
store, err := cloudstorage.NewStore(config)
if err != nil {
t.Logf("No valid auth provided, skipping azure testing %v", err)
t.Skip()
return
}
client := store.Client()
assert.NotEqual(t, nil, client)
testutils.RunTests(t, store)
}