/
koofrlib_suite_test.go
77 lines (60 loc) · 1.31 KB
/
koofrlib_suite_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
69
70
71
72
73
74
75
76
77
package koofrclient_test
import (
"os"
"strings"
"testing"
k "github.com/koofr/go-koofrclient"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var (
client *k.KoofrClient
apiBase string
rootPath string
email string
password string
defaultMountId string
)
func TestKoofrclient(t *testing.T) {
RegisterFailHandler(Fail)
apiBase = os.Getenv("KOOFR_APIBASE")
if apiBase == "" {
t.Fatal("Missing KOOFR_APIBASE")
}
rootPath = os.Getenv("KOOFR_ROOTPATH")
if rootPath == "" {
t.Fatal("Missing KOOFR_ROOTPATH")
}
if !strings.HasPrefix(rootPath, "/") {
rootPath = "/" + rootPath
}
email = os.Getenv("KOOFR_EMAIL")
if email == "" {
t.Fatal("Missing KOOFR_EMAIL")
}
password = os.Getenv("KOOFR_PASSWORD")
if password == "" {
t.Fatal("Missing KOOFR_PASSWORD")
}
client = k.NewKoofrClient(apiBase, true)
err := client.Authenticate(email, password)
if err != nil {
t.Fatal("Koofr authorization failed")
}
mounts, err := client.Mounts()
if err != nil {
t.Fatal("Koofr listing mounts failed")
}
if len(mounts) == 0 {
t.Fatal("Koofr mounts must not be empty")
}
for _, m := range mounts {
if m.IsPrimary {
defaultMountId = m.Id
}
}
if defaultMountId == "" {
t.Fatal("Koofr primary mount not found")
}
RunSpecs(t, "Koofrclient Suite")
}