-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
72 lines (56 loc) · 1.38 KB
/
client_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 harper
import (
"crypto/tls"
"fmt"
"strings"
"testing"
"time"
"github.com/google/uuid"
)
const (
DEFAULT_ENDPOINT = "http://localhost:9925"
DEFAULT_USERNAME = "HDB_ADMIN"
DEFAULT_PASSWORD = "password"
)
var (
c *Client
)
func init() {
c = createClient()
}
func createClient() *Client {
return NewClient(DEFAULT_ENDPOINT, DEFAULT_USERNAME, DEFAULT_PASSWORD)
}
func wait() {
// Some operations are asynchronously propagated between processes, so
// while the objects are created they are not immediately visible
time.Sleep(200 * time.Millisecond)
}
func randomID() string {
return fmt.Sprintf("id_%s", strings.ReplaceAll(uuid.NewString(), "-", "_"))
}
func TestNewClient(t *testing.T) {
_, err := c.RegistrationInfo()
if err != nil {
t.Fatal(err)
}
}
func TestGetFingerprint(t *testing.T) {
_, err := c.GetFingerprint()
if err != nil {
t.Fatal(err)
}
}
func ExampleNewClient() {
// Connecting to a Harper instance
c := NewClient("http://localhost:9925", "HDB_ADMIN", "password")
// (optional) set some proxy
c.HttpClient.SetProxy("http://localhost:8888")
}
func ExampleNewClient_https() {
// Connecting to a Harper instance
c := NewClient("https://localhost:31283", "HDB_ADMIN", "password")
// with a self-signed certificate
// will most likely fail so disable security check (https)
c.HttpClient.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
}