-
Notifications
You must be signed in to change notification settings - Fork 52
/
wrap_test.go
64 lines (52 loc) · 1.3 KB
/
wrap_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
//go:build darwin
package fsevents
import (
"testing"
"time"
)
func TestCreatePath(t *testing.T) {
ref, err := createPaths([]string{"/a", "/b"})
if err != nil {
t.Fatal(err)
}
if e := 2; cfArrayLen(ref) != e {
t.Errorf("got: %d wanted: %d", cfArrayLen(ref), e)
}
}
func TestEventStream(t *testing.T) {
eid := uint64(42)
did := int32(12)
paths := []string{"/a", "/b"}
ref := setupStream(paths, 0, 0, eid, time.Duration(0), did)
if e := getStreamRefEventID(ref); eid != e {
t.Errorf("got: %d wanted: %d", e, eid)
}
if e := getStreamRefDeviceID(ref); did != e {
t.Errorf("got: %d wanted: %d", e, did)
}
spaths := getStreamRefPaths(ref)
for i := range paths {
if paths[i] != spaths[i] {
t.Errorf("pos %d got: %s wanted: %s", i, spaths[i], paths[i])
}
}
}
func TestDeviceID(t *testing.T) {
// Verify compatible devide ID is returned
// Probably a way to verify this UUID as well...
did, err := DeviceForPath("/")
if err != nil {
t.Fatal(err)
}
if len(GetDeviceUUID(did)) == 0 {
t.Fatal("failed to read device ID")
}
}
func TestEventIDSinceNow(t *testing.T) {
// from FSEvents.h:
// kFSEventStreamEventIdSinceNow = 0xFFFFFFFFFFFFFFFFULL
const expected = uint64(0xFFFFFFFFFFFFFFFF)
if eventIDSinceNow != expected {
t.Errorf("got: %v wanted: %v", eventIDSinceNow, expected)
}
}