forked from luthermonson/go-proxmox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_test.go
56 lines (46 loc) · 1.14 KB
/
cluster_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
package proxmox
import (
"context"
"testing"
"github.com/ParminCloud/go-proxmox/tests/mocks"
"github.com/stretchr/testify/assert"
)
func TestCluster(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
cluster, err := client.Cluster(ctx)
assert.Nil(t, err)
assert.Equal(t, 4, cluster.Version)
assert.Equal(t, "cluster", cluster.ID)
for _, n := range cluster.Nodes {
assert.Contains(t, n.ID, "node/node")
assert.Equal(t, "node", n.Type)
}
}
func TestNextID(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
cluster, err := client.Cluster(ctx)
assert.Nil(t, err)
nextid, err := cluster.NextID(ctx)
assert.Nil(t, err)
assert.Equal(t, 100, nextid)
}
func TestCluster_Resources(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
cluster, err := client.Cluster(ctx)
assert.Nil(t, err)
// json unmarshaling tests
rs, err := cluster.Resources(ctx)
assert.Equal(t, 20, len(rs))
// type param test
rs, err = cluster.Resources(ctx, "node")
assert.Equal(t, 1, len(rs))
}