forked from revel/revel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multipletest.go
41 lines (35 loc) · 1.09 KB
/
multipletest.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
package tests
import (
"net/url"
"path"
"github.com/revel/revel/samples/upload/app/routes"
"github.com/revel/revel"
)
// MultipleTest is a test suite of Multiple controller.
type MultipleTest struct {
revel.TestSuite
}
// TestThatMultipleFilesUploadWorks makes sure that Multiple.HandleUpload requires
// multiple files to be uploaded.
func (t *MultipleTest) TestThatMultipleFilesUploadWorks() {
// Make sure it is not allowed to submit less than 2 files.
t.PostFile(routes.Multiple.HandleUpload(), url.Values{}, url.Values{
"file": {
path.Join(revel.BasePath, "public/img/favicon.png"),
},
})
t.AssertOk()
t.AssertContains("You cannot submit less than 2 files")
// Make sure upload of 2 files works.
t.PostFile(routes.Multiple.HandleUpload(), url.Values{}, url.Values{
"file[]": {
path.Join(revel.BasePath, "public/img/favicon.png"),
path.Join(revel.BasePath, "public/img/glyphicons-halflings.png"),
},
})
t.AssertOk()
t.AssertContains("Successfully uploaded")
t.AssertContains("favicon.png")
t.AssertContains("glyphicons-halflings.png")
t.AssertContains("image/png")
}