-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfs_test.go
78 lines (64 loc) · 1.65 KB
/
fs_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
70
71
72
73
74
75
76
77
78
package gitfs
import (
"io/fs"
"reflect"
"sort"
"strings"
"testing"
"testing/fstest"
)
func TestFS(t *testing.T) {
t.Parallel()
fsys, err := New("https://github.com/forensicanalysis/fslib")
if err != nil {
t.Fatal(err)
}
err = fstest.TestFS(fsys, "LICENSE")
if err != nil {
t.Fatal(err)
}
}
func TestNew(t *testing.T) {
t.Parallel()
want := strings.Split(".gitignore LICENSE Makefile README.md appveyor.yml "+
"bolt_386.go bolt_amd64.go bolt_arm.go bolt_arm64.go bolt_linux.go bolt_openbsd.go "+
"bolt_ppc.go bolt_ppc64.go bolt_ppc64le.go bolt_s390x.go bolt_unix.go bolt_unix_solaris.go "+
"bolt_windows.go boltsync_unix.go bucket.go bucket_test.go cmd cursor.go cursor_test.go "+
"db.go db_test.go doc.go errors.go freelist.go freelist_test.go node.go node_test.go "+
"page.go page_test.go quick_test.go simulation_test.go tx.go tx_test.go", " ")
type args struct {
url string
}
tests := []struct {
name string
args args
want []string
wantErr bool
}{
{"New", args{"https://github.com/boltdb/bolt"}, want, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
fsys, err := New(tt.args.url)
if (err != nil) != tt.wantErr {
t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)
return
}
var names []string
entries, err := fs.ReadDir(fsys, ".")
if err != nil {
t.Errorf("New() error = %v", err)
return
}
for _, entry := range entries {
names = append(names, entry.Name())
}
sort.Strings(names)
sort.Strings(tt.want)
if !reflect.DeepEqual(names, tt.want) {
t.Errorf("New() got = %v, want %v", names, tt.want)
}
})
}
}