mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-22 08:23:50 +01:00
33 lines
819 B
Go
33 lines
819 B
Go
package zfs
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestZFSListHandlesProducesZFSErrorOnNonZeroExit(t *testing.T) {
|
|
t.SkipNow() // FIXME ZFS_BINARY does not work if tests run in parallel
|
|
|
|
var err error
|
|
|
|
ZFS_BINARY = "./test_helpers/zfs_failer.sh"
|
|
|
|
_, err = ZFSList([]string{"fictionalprop"}, "nonexistent/dataset")
|
|
|
|
assert.Error(t, err)
|
|
zfsError, ok := err.(ZFSError)
|
|
assert.True(t, ok)
|
|
assert.Equal(t, "error: this is a mock\n", string(zfsError.Stderr))
|
|
}
|
|
|
|
func TestDatasetPathTrimNPrefixComps(t *testing.T) {
|
|
p, err := NewDatasetPath("foo/bar/a/b")
|
|
assert.Nil(t, err)
|
|
p.TrimNPrefixComps(2)
|
|
assert.True(t, p.Equal(toDatasetPath("a/b")))
|
|
p.TrimNPrefixComps((2))
|
|
assert.True(t, p.Empty())
|
|
p.TrimNPrefixComps((1))
|
|
assert.True(t, p.Empty(), "empty trimming shouldn't do harm")
|
|
}
|