-
Notifications
You must be signed in to change notification settings - Fork 50
/
pools_test.go
80 lines (66 loc) · 1.57 KB
/
pools_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
73
74
75
76
77
78
79
80
package proxmox
import (
"context"
"testing"
"github.com/luthermonson/go-proxmox/tests/mocks"
"github.com/stretchr/testify/assert"
)
func TestPools(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
pools, err := client.Pools(context.Background())
assert.Nil(t, err)
assert.Len(t, pools, 1)
}
func TestPoolGet(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
pool, err := client.Pool(context.Background(), "test-pool")
assert.Nil(t, err)
assert.NotNil(t, pool)
if pool != nil {
assert.Equal(t, "test-pool", pool.PoolID)
assert.Equal(t, "Test pool", pool.Comment)
assert.Len(t, pool.Members, 3)
}
}
func TestPoolCreate(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
err := client.NewPool(context.Background(), "test-pool", "Test pool")
assert.Nil(t, err)
}
func TestPoolUpdate(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
pool, err := client.Pool(ctx, "test-pool")
assert.Nil(t, err)
assert.NotNil(t, pool)
if pool != nil {
err = pool.Update(ctx, &PoolUpdateOption{
Comment: "Test pool updated",
Delete: true,
Storage: "local-zfs",
VirtualMachines: "100",
})
assert.Nil(t, err)
}
}
func TestPoolDelete(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
client := mockClient()
ctx := context.Background()
pool, err := client.Pool(ctx, "test-pool")
assert.Nil(t, err)
assert.NotNil(t, pool)
if pool != nil {
err = pool.Delete(ctx)
assert.Nil(t, err)
}
}