-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathnodes_ceph_cfg_test.go
More file actions
66 lines (54 loc) · 1.89 KB
/
Copy pathnodes_ceph_cfg_test.go
File metadata and controls
66 lines (54 loc) · 1.89 KB
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
package proxmox
import (
"context"
"testing"
"github.com/luthermonson/go-proxmox/tests/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestNode_CephCfg(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
entries, err := cephNode().CephCfg(context.Background())
require.NoError(t, err)
require.Len(t, entries, 3)
names := []interface{}{entries[0]["name"], entries[1]["name"], entries[2]["name"]}
assert.Contains(t, names, "db")
assert.Contains(t, names, "raw")
assert.Contains(t, names, "value")
}
func TestNode_CephCfgDB(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
entries, err := cephNode().CephCfgDB(context.Background())
require.NoError(t, err)
require.Len(t, entries, 2)
assert.Equal(t, "global", entries[0].Section)
assert.Equal(t, "auth-cluster-required", entries[0].Name)
assert.Equal(t, "cephx", entries[0].Value)
assert.Equal(t, "basic", entries[0].Level)
assert.False(t, bool(entries[0].CanUpdateAtRuntime))
assert.Equal(t, "osd", entries[1].Section)
assert.Equal(t, "osd-pool-default-size", entries[1].Name)
assert.Equal(t, "3", entries[1].Value)
assert.True(t, bool(entries[1].CanUpdateAtRuntime))
}
func TestNode_CephCfgRaw(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
raw, err := cephNode().CephCfgRaw(context.Background())
require.NoError(t, err)
assert.Contains(t, raw, "[global]")
assert.Contains(t, raw, "auth_cluster_required = cephx")
}
func TestNode_CephCfgValue(t *testing.T) {
mocks.On(mockConfig)
defer mocks.Off()
values, err := cephNode().CephCfgValue(context.Background(), "global:auth_cluster_required;osd:osd_pool_default_size")
require.NoError(t, err)
require.NotNil(t, values)
assert.Equal(t, "cephx", values["global"]["auth-cluster-required"])
assert.Equal(t, "3", values["osd"]["osd-pool-default-size"])
_, err = cephNode().CephCfgValue(context.Background(), "")
assert.Error(t, err)
}