-
Notifications
You must be signed in to change notification settings - Fork 49
/
nodes_test.go
44 lines (36 loc) · 904 Bytes
/
nodes_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
package proxmox
import (
"context"
"testing"
"github.com/luthermonson/go-proxmox/tests/mocks"
"github.com/stretchr/testify/assert"
)
func TestClient_Nodes(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
nodes, err := client.Nodes(ctx)
assert.Nil(t, err)
for _, n := range nodes {
assert.Contains(t, n.Node, "node")
assert.Equal(t, n.Type, "node")
}
//assert.Equal(t, 6, len(testData))
}
func TestClient_Node(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
node, err := client.Node(ctx, "node1")
assert.Nil(t, err)
assert.Equal(t, "node1", node.Name)
assert.NotNil(t, node.client)
v, err := node.Version(ctx)
assert.Nil(t, err)
assert.Equal(t, "7.4", v.Release)
node, err = client.Node(ctx, "doesntexist")
assert.NotNil(t, err)
assert.Nil(t, node)
}