-
Notifications
You must be signed in to change notification settings - Fork 44
/
hardlinks_test.go
57 lines (49 loc) · 1.05 KB
/
hardlinks_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
package fsutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidHardlinks(t *testing.T) {
err := checkHardlinks(changeStream([]string{
"ADD foo file",
"ADD foo2 file >foo",
}))
assert.NoError(t, err)
}
func TestInvalideHardlinks(t *testing.T) {
err := checkHardlinks(changeStream([]string{
"ADD foo file >foo2",
"ADD foo2 file",
}))
assert.Error(t, err)
}
func TestInvalideHardlinks2(t *testing.T) {
err := checkHardlinks(changeStream([]string{
"ADD foo file",
"ADD foo2 file >bar",
}))
assert.Error(t, err)
}
func TestHardlinkToDir(t *testing.T) {
err := checkHardlinks(changeStream([]string{
"ADD foo dir",
"ADD foo2 file >foo",
}))
assert.Error(t, err)
}
func TestHardlinkToSymlink(t *testing.T) {
err := checkHardlinks(changeStream([]string{
"ADD foo symlink /",
"ADD foo2 file >foo",
}))
assert.Error(t, err)
}
func checkHardlinks(inp []*change) error {
h := &Hardlinks{}
for _, c := range inp {
if err := h.HandleChange(c.kind, c.path, c.fi, nil); err != nil {
return err
}
}
return nil
}