zfs: ability to specify sources for zfsGet

fix use for Placeholder, leave rest as previous behavior
This commit is contained in:
Christian Schwarz
2018-09-05 19:44:35 -07:00
parent 975fdee217
commit 1323a30a0c
4 changed files with 78 additions and 10 deletions

View File

@ -30,3 +30,41 @@ func TestDatasetPathTrimNPrefixComps(t *testing.T) {
p.TrimNPrefixComps((1))
assert.True(t, p.Empty(), "empty trimming shouldn't do harm")
}
func TestZFSPropertySource(t *testing.T) {
tcs := []struct{
in zfsPropertySource
exp []string
}{
{
in: sourceAny,
exp: []string{"local", "default", "inherited", "-", "temporary"},
},
{
in: sourceTemporary,
exp: []string{"temporary"},
},
{
in: sourceLocal|sourceInherited,
exp: []string{"local", "inherited"},
},
}
toSet := func(in []string) map[string]struct{} {
m := make(map[string]struct{}, len(in))
for _, s := range in {
m[s] = struct{}{}
}
return m
}
for _, tc := range tcs {
res := tc.in.zfsGetSourceFieldPrefixes()
resSet := toSet(res)
expSet := toSet(tc.exp)
assert.Equal(t, expSet, resSet)
}
}