-
Notifications
You must be signed in to change notification settings - Fork 3
/
file_upload_test.go
50 lines (41 loc) · 1.03 KB
/
file_upload_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
package req
import "testing"
func TestErrorOpenFile(t *testing.T) {
fd, err := FileUploadFromDisk("I am Not A File")
if err == nil {
t.Error("We are not getting an error back from our non existent file: ")
}
if fd != nil {
t.Error("We actually got back a pointer: ", fd)
}
}
func TestGLOBFiles(t *testing.T) {
fd, err := FileUploadFromGlob("testdata/*")
if err != nil {
t.Error("Got an invalid GLOB: ", err)
}
if len(fd) != 2 {
t.Error("Some how we have more than two files in our glob", len(fd), fd)
}
}
func TestInvalidGlob(t *testing.T) {
if _, err := FileUploadFromGlob("[-]"); err == nil {
t.Error("Somehow the glob worked")
}
}
func TestNoGlobFiles(t *testing.T) {
if _, err := FileUploadFromGlob("notapath"); err == nil {
t.Error("Somehow got a valid GLOB")
}
}
func TestGlobWithDir(t *testing.T) {
fd, err := FileUploadFromGlob("*test*")
if err != nil {
t.Error("Glob failed", err)
}
for _, f := range fd {
if f.FileName == "test_files" {
t.Error(f, "is a dir (which cannot be uploaded)")
}
}
}