forked from bicomsystems/go-libzfs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bookmark_test.go
executable file
·69 lines (65 loc) · 1.27 KB
/
bookmark_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
package zfs
import (
"testing"
)
func TestBookmark(t *testing.T) {
testDatasetName := *testPool + "/tank1"
testSnapshotName := testDatasetName + "@test"
snap, err := DatasetSnapshot(testSnapshotName, false, nil)
if err != nil {
t.Fatal(err)
} else {
snap.Close()
}
t.Run("bookmark a dataset that is filesystem", func(t *testing.T) {
ds, err := DatasetOpen(testDatasetName)
if err != nil {
t.Fatal(err)
return
}
defer ds.Close()
bm, err := ds.CreateBookmark("#last")
if err == nil {
defer bm.Close()
t.Fatal("have to return an error")
}
t.Log(err)
})
t.Run("bookmark a snapshot exists", func(t *testing.T) {
ds, err := DatasetOpen(testSnapshotName)
if err != nil {
t.Error(err)
return
}
defer ds.Close()
bm, err := ds.CreateBookmark("last")
if err != nil {
t.Fatal("error: ", err)
}
defer bm.Close()
t.Log(bm)
})
t.Run("delete a bookmark", func(t *testing.T) {
ds, err := DatasetOpen(testDatasetName + "#last")
if err != nil {
t.Error(err)
return
}
defer ds.Close()
err = ds.Destroy(false)
if err != nil {
t.Fatal(err)
}
})
ds, err := DatasetOpen(testSnapshotName)
if err != nil {
t.Error(err)
return
} else {
err = ds.Destroy(false)
if err != nil {
t.Fatal(err)
}
ds.Close()
}
}