zrepl/platformtest/tests/getNonexistent.go
Christian Schwarz b9933f6cb2 platformtest: add zfsGet bookmark handling & replicationCursor tests
This encodes the observation made in issue #230 :
In the ZFS version shipped in Ubuntu 16.04 where
`zfs get someprop a#bookmark` does not work.
2019-10-14 17:54:14 +02:00

65 lines
1.4 KiB
Go

package tests
import (
"fmt"
"github.com/zrepl/zrepl/platformtest"
"github.com/zrepl/zrepl/zfs"
)
func GetNonexistent(ctx *platformtest.Context) {
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
DESTROYROOT
CREATEROOT
+ "foo bar"
+ "foo bar@1"
`)
// test raw
_, err := zfs.ZFSGetRawAnySource(fmt.Sprintf("%s/foo bar", ctx.RootDataset), []string{"name"})
if err != nil {
panic(err)
}
// test nonexistent filesystem
nonexistent := fmt.Sprintf("%s/nonexistent filesystem", ctx.RootDataset)
props, err := zfs.ZFSGetRawAnySource(nonexistent, []string{"name"})
if err == nil {
panic(props)
}
dsne, ok := err.(*zfs.DatasetDoesNotExist)
if !ok {
panic(err)
} else if dsne.Path != nonexistent {
panic(err)
}
// test nonexistent snapshot
nonexistent = fmt.Sprintf("%s/foo bar@non existent", ctx.RootDataset)
props, err = zfs.ZFSGetRawAnySource(nonexistent, []string{"name"})
if err == nil {
panic(props)
}
dsne, ok = err.(*zfs.DatasetDoesNotExist)
if !ok {
panic(err)
} else if dsne.Path != nonexistent {
panic(err)
}
// test nonexistent bookmark
nonexistent = fmt.Sprintf("%s/foo bar#non existent", ctx.RootDataset)
props, err = zfs.ZFSGetRawAnySource(nonexistent, []string{"name"})
if err == nil {
panic(props)
}
dsne, ok = err.(*zfs.DatasetDoesNotExist)
if !ok {
panic(err)
} else if dsne.Path != nonexistent {
panic(err)
}
}