2020-05-24 17:49:16 +02:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2020-08-31 16:04:00 +02:00
|
|
|
|
2024-10-18 19:21:17 +02:00
|
|
|
"github.com/zrepl/zrepl/internal/platformtest"
|
|
|
|
"github.com/zrepl/zrepl/internal/zfs"
|
2020-05-24 17:49:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func HoldsWork(ctx *platformtest.Context) {
|
|
|
|
platformtest.Run(ctx, platformtest.PanicErr, ctx.RootDataset, `
|
|
|
|
DESTROYROOT
|
|
|
|
CREATEROOT
|
|
|
|
+ "foo bar"
|
|
|
|
+ "foo bar@snap name"
|
|
|
|
`)
|
|
|
|
|
|
|
|
fs := path.Join(ctx.RootDataset, "foo bar")
|
|
|
|
|
|
|
|
err := zfs.ZFSHold(ctx, fs, fsversion(ctx, fs, "@snap name"), "tag 1")
|
|
|
|
require.NoError(ctx, err)
|
|
|
|
|
|
|
|
err = zfs.ZFSHold(ctx, fs, fsversion(ctx, fs, "@snap name"), "tag 2")
|
|
|
|
require.NoError(ctx, err)
|
|
|
|
|
|
|
|
holds, err := zfs.ZFSHolds(ctx, fs, "snap name")
|
|
|
|
require.NoError(ctx, err)
|
|
|
|
require.Len(ctx, holds, 2)
|
|
|
|
require.Contains(ctx, holds, "tag 1")
|
|
|
|
require.Contains(ctx, holds, "tag 2")
|
|
|
|
}
|