-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataset_test.go
86 lines (79 loc) · 2.29 KB
/
dataset_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
81
82
83
84
85
86
package zfs
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_readDatasets(t *testing.T) {
in := splitOutput(testInput)
const prop1 = "nl.test:hiephoi"
const prop2 = "nl.test:eigenschap"
ds, err := readDatasets(in, []string{prop1, prop2})
require.NoError(t, err)
require.Len(t, ds, 3)
require.Equal(t, ds[0].Name, "testpool/ds0")
require.Equal(t, ds[1].Name, "testpool/ds1")
require.Equal(t, ds[2].Name, "testpool/ds10")
for i := range ds {
require.Equal(t, "", ds[i].Origin)
require.NotEmpty(t, ds[i].Name)
require.NotEmpty(t, ds[i].Mountpoint)
require.True(t, ds[i].Mounted || i == 2)
require.NotZero(t, ds[i].Referenced)
require.NotZero(t, ds[i].Used)
require.NotZero(t, ds[i].Available)
require.Equal(t, "42", ds[i].ExtraProps[prop1])
require.Equal(t, "ja", ds[i].ExtraProps[prop2])
}
}
const testInput = `testpool/ds0 name testpool/ds0
testpool/ds0 type filesystem
testpool/ds0 origin -
testpool/ds0 used 196416
testpool/ds0 available 186368146928528
testpool/ds0 mounted yes
testpool/ds0 mountpoint none
testpool/ds0 compression off
testpool/ds0 volsize -
testpool/ds0 quota 0
testpool/ds0 refquota 0
testpool/ds0 referenced 196416
testpool/ds0 written 196416
testpool/ds0 logicalused 43520
testpool/ds0 usedbydataset 196416
testpool/ds0 nl.test:hiephoi 42
testpool/ds0 nl.test:eigenschap ja
testpool/ds1 name testpool/ds1
testpool/ds1 type filesystem
testpool/ds1 origin -
testpool/ds1 used 196416
testpool/ds1 available 186368146928528
testpool/ds1 mounted yes
testpool/ds1 mountpoint none
testpool/ds1 compression off
testpool/ds1 volsize -
testpool/ds1 quota 0
testpool/ds1 refquota 0
testpool/ds1 referenced 196416
testpool/ds1 written 196416
testpool/ds1 logicalused 43520
testpool/ds1 usedbydataset 196416
testpool/ds1 nl.test:hiephoi 42
testpool/ds1 nl.test:eigenschap ja
testpool/ds10 name testpool/ds10
testpool/ds10 type filesystem
testpool/ds10 origin -
testpool/ds10 used 196416
testpool/ds10 available 186368146928528
testpool/ds10 mounted no
testpool/ds10 mountpoint none
testpool/ds10 compression off
testpool/ds10 volsize -
testpool/ds10 quota 0
testpool/ds10 refquota 0
testpool/ds10 referenced 196416
testpool/ds10 written 196416
testpool/ds10 logicalused 43520
testpool/ds10 usedbydataset 196416
testpool/ds10 nl.test:hiephoi 42
testpool/ds10 nl.test:eigenschap ja
`