-
Notifications
You must be signed in to change notification settings - Fork 29
/
aiven_go_client_suite_test.go
58 lines (48 loc) · 1.14 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
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
)
projectName := os.Getenv("AIVEN_PROJECT_NAME")
if projectName == "" {
Fail("cannot create Aiven API client, `AIVEN_PROJECT_NAME` is required")
}
client, err = SetupEnvClient("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)
}