forked from aiven/aiven-go-client
-
Notifications
You must be signed in to change notification settings - Fork 1
/
aiven_go_client_suite_test.go
72 lines (59 loc) · 1.39 KB
/
aiven_go_client_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
package aiven
import (
"math/rand"
"os"
"strconv"
"testing"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestAivenGoClient(t *testing.T) {
if os.Getenv("AIVEN_ACC") != "" {
RegisterFailHandler(Fail)
RunSpecs(t, "AivenGoClient Suite")
}
}
var (
client *Client
)
var _ = BeforeSuite(func() {
var (
err error
)
url := os.Getenv("AIVEN_WEB_URL")
if url == "" {
Fail("environment variable `AIVEN_WEB_URL` is not set")
}
apiurl = url + "/v1"
token := os.Getenv("AIVEN_TOKEN")
if token == "" {
Fail("cannot create Aiven API client, `AIVEN_TOKEN` is required")
}
cardId := os.Getenv("AIVEN_PROJECT_NAME")
if cardId == "" {
Fail("cannot create Aiven API client, `AIVEN_PROJECT_NAME` is required")
}
client, err = NewTokenClient(
token,
"aiven-go-client-test/")
if err != nil {
Fail("cannot create Aiven API client :" + err.Error())
}
})
var _ = Describe("Check client", func() {
Context("Create new client using username and password", func() {
It("should be valid client", func() {
Expect(client.Client).NotTo(BeNil())
})
It("should have an API token", func() {
Expect(client.APIKey).NotTo(Equal("some-random-token"))
Expect(client.APIKey).NotTo(BeEmpty())
})
})
})
// generateRandomString generate a random id
func generateRandomID() string {
var src = rand.NewSource(time.Now().UnixNano())
return strconv.FormatInt(src.Int63(), 10)
}