-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclient_test.go
More file actions
47 lines (36 loc) · 820 Bytes
/
client_test.go
File metadata and controls
47 lines (36 loc) · 820 Bytes
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
package ztcentral
import (
"context"
"testing"
"time"
"github.com/zerotier/go-ztcentral/pkg/testutil"
)
func TestErrors(t *testing.T) {
testutil.NeedsToken(t)
c, err := NewClient(testutil.InitTokenFromEnv())
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
_, err = c.GetMember(ctx, "1", "1")
if err == nil {
t.Fatal("did not error")
}
}
func TestUser(t *testing.T) {
testutil.NeedsToken(t)
c, err := NewClient(testutil.InitTokenFromEnv())
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
user, err := c.User(ctx)
if err != nil {
t.Fatal(err)
}
if user == nil || user.Id == nil || len(*user.Id) == 0 {
t.Fatal("UserID was nil or empty")
}
}