forked from ceph/go-ceph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_test.go
41 lines (35 loc) · 942 Bytes
/
command_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
package cephfs
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMdsCommand(t *testing.T) {
mount := fsConnect(t)
defer fsDisconnect(t, mount)
cmd := []byte(`{"prefix": "client ls"}`)
buf, info, err := mount.MdsCommand(
testMdsName,
[][]byte{cmd})
assert.NoError(t, err)
assert.NotEqual(t, "", string(buf))
assert.Equal(t, "", string(info))
assert.Contains(t, string(buf), "ceph_version")
// response should also be valid json
var j []interface{}
err = json.Unmarshal(buf, &j)
assert.NoError(t, err)
assert.GreaterOrEqual(t, len(j), 1)
}
func TestMdsCommandError(t *testing.T) {
mount := fsConnect(t)
defer fsDisconnect(t, mount)
cmd := []byte("iAMinValId~~~")
buf, info, err := mount.MdsCommand(
testMdsName,
[][]byte{cmd})
assert.Error(t, err)
assert.Equal(t, "", string(buf))
assert.NotEqual(t, "", string(info))
assert.Contains(t, string(info), "unparseable JSON")
}