10 func TestSliceFiles(t *testing.T) {
11 sf := NewMapDirectory(map[string]Node{
12 "1": NewBytesFile([]byte("Some text!\n")),
13 "2": NewBytesFile([]byte("beep")),
14 "3": NewBytesFile([]byte("boop")),
17 CheckDir(t, sf, []Event{
21 value: "Some text!\n",
36 func TestReaderFiles(t *testing.T) {
37 message := "beep boop"
38 rf := NewBytesFile([]byte(message))
39 buf := make([]byte, len(message))
41 if n, err := rf.Read(buf); n == 0 || err != nil {
42 t.Fatal("Expected to be able to read")
44 if err := rf.Close(); err != nil {
45 t.Fatal("Should be able to close")
47 if n, err := rf.Read(buf); n != 0 || err != io.EOF {
48 t.Fatal("Expected EOF when reading after close")
51 func TestMultipartFiles(t *testing.T) {
54 Content-Type: text/plain
55 Content-Disposition: file; filename="name"
60 Content-Type: application/x-directory
61 Content-Disposition: file; filename="dir"
64 Content-Type: text/plain
65 Content-Disposition: file; filename="dir/nested"
69 Content-Type: application/symlink
70 Content-Disposition: file; filename="dir/simlynk"
74 Content-Type: text/plain
75 Content-Disposition: file; filename="implicit1/implicit2/deep_implicit"
79 Content-Type: text/plain
80 Content-Disposition: file; filename="implicit1/shallow_implicit"
87 reader := strings.NewReader(data)
88 mpReader := multipart.NewReader(reader, "Boundary!")
89 dir, err := NewFileFromPartReader(mpReader, multipartFormdataType)
94 CheckDir(t, dir, []Event{
107 value: "some content",
112 value: "anotherfile",
127 name: "deep_implicit",
128 value: "implicit file1",
135 name: "shallow_implicit",
136 value: "implicit file2",