-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathdirectory_browser_test.go
More file actions
45 lines (34 loc) · 971 Bytes
/
Copy pathdirectory_browser_test.go
File metadata and controls
45 lines (34 loc) · 971 Bytes
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
package ext4
import (
"io"
"reflect"
"sort"
"testing"
"github.com/dsoprea/go-logging"
)
func TestDirectoryBrowser_Next(t *testing.T) {
f, inode, err := GetTestInode(TestDirectoryInodeNumber)
log.PanicIf(err)
defer f.Close()
db := NewDirectoryBrowser(f, inode)
entryDescriptions := make([]string, 0)
for {
de, err := db.Next()
if err == io.EOF {
break
} else if err != nil {
log.Panic(err)
}
entryDescriptions = append(entryDescriptions, de.String())
}
sort.Strings(entryDescriptions)
expectedEntryDescriptions := []string{
"DirectoryEntry<NAME=[..] INODE=(2) TYPE=[directory]-(2)>",
"DirectoryEntry<NAME=[.] INODE=(2) TYPE=[directory]-(2)>",
"DirectoryEntry<NAME=[lost+found] INODE=(11) TYPE=[directory]-(2)>",
"DirectoryEntry<NAME=[thejungle.txt] INODE=(12) TYPE=[regular]-(1)>",
}
if reflect.DeepEqual(entryDescriptions, expectedEntryDescriptions) == false {
t.Fatalf("Root directory entries are not correct.")
}
}