Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5cb6c2

Browse filesBrowse files
committed
Merge pull request revel#759 from anonx/tests/enhancement
Include upload sample's tests in travis
2 parents 1e74f27 + c0c3004 commit f5cb6c2
Copy full SHA for f5cb6c2

File tree

Expand file treeCollapse file tree

3 files changed

+22
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+22
-6
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ script:
4040
- revel test github.com/revel/revel/samples/validation
4141
- sleep 30
4242
- revel test github.com/revel/revel/samples/persona
43+
- sleep 30
44+
- revel test github.com/revel/revel/samples/upload

‎samples/upload/tests/multipletest.go

Copy file name to clipboardExpand all lines: samples/upload/tests/multipletest.go
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ package tests
22

33
import (
44
"net/url"
5+
"path"
56

67
"github.com/revel/revel/samples/upload/app/routes"
78

89
"github.com/revel/revel"
910
)
1011

12+
// MultipleTest is a test suite of Multiple controller.
1113
type MultipleTest struct {
1214
revel.TestSuite
1315
}
1416

17+
// TestThatMultipleFilesUploadWorks makes sure that Multiple.HandleUpload requires
18+
// multiple files to be uploaded.
1519
func (t *MultipleTest) TestThatMultipleFilesUploadWorks() {
1620
// Make sure it is not allowed to submit less than 2 files.
1721
t.PostFile(routes.Multiple.HandleUpload(), url.Values{}, url.Values{
1822
"file": {
19-
"github.com/revel/revel/samples/upload/public/img/favicon.png",
23+
path.Join(revel.BasePath, "public/img/favicon.png"),
2024
},
2125
})
2226
t.AssertOk()
@@ -25,8 +29,8 @@ func (t *MultipleTest) TestThatMultipleFilesUploadWorks() {
2529
// Make sure upload of 2 files works.
2630
t.PostFile(routes.Multiple.HandleUpload(), url.Values{}, url.Values{
2731
"file[]": {
28-
"github.com/revel/revel/samples/upload/public/img/favicon.png",
29-
"github.com/revel/revel/samples/upload/public/img/glyphicons-halflings.png",
32+
path.Join(revel.BasePath, "public/img/favicon.png"),
33+
path.Join(revel.BasePath, "public/img/glyphicons-halflings.png"),
3034
},
3135
})
3236
t.AssertOk()

‎samples/upload/tests/singletest.go

Copy file name to clipboardExpand all lines: samples/upload/tests/singletest.go
+13-3Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ package tests
22

33
import (
44
"net/url"
5+
"path"
56

67
"github.com/revel/revel"
78
)
89

10+
// SingleTest is a test suite of Multiple controller.
911
type SingleTest struct {
1012
revel.TestSuite
1113
}
1214

15+
// TestThatSingleAvatarUploadWorks checks whether Signle.HandleUpload doesn't let users
16+
// upload anything but only image files of type JPG and PNG with a specific resolution and size.
1317
func (t *SingleTest) TestThatSingleAvatarUploadWorks() {
1418
// Make sure file is required.
1519
t.PostFile("/single/HandleUpload", url.Values{}, url.Values{
@@ -21,21 +25,27 @@ func (t *SingleTest) TestThatSingleAvatarUploadWorks() {
2125

2226
// Make sure incorrect format is not being accepted.
2327
t.PostFile("/single/HandleUpload", url.Values{}, url.Values{
24-
"avatar": {"github.com/revel/revel/samples/upload/public/css/bootstrap.css"},
28+
"avatar": {
29+
path.Join(revel.BasePath, "public/css/bootstrap.css"),
30+
},
2531
})
2632
t.AssertOk()
2733
t.AssertContains("Incorrect file format")
2834

2935
// Ensure low resolution avatar cannot be uploaded.
3036
t.PostFile("/single/HandleUpload", url.Values{}, url.Values{
31-
"avatar": {"github.com/revel/revel/samples/upload/public/img/favicon.png"},
37+
"avatar": {
38+
path.Join(revel.BasePath, "public/img/favicon.png"),
39+
},
3240
})
3341
t.AssertOk()
3442
t.AssertContains("Minimum allowed resolution is 150x150px")
3543

3644
// Check whether correct avatar is uploaded.
3745
t.PostFile("/single/HandleUpload", url.Values{}, url.Values{
38-
"avatar": {"github.com/revel/revel/samples/upload/public/img/glyphicons-halflings.png"},
46+
"avatar": {
47+
path.Join(revel.BasePath, "public/img/glyphicons-halflings.png"),
48+
},
3949
})
4050
t.AssertOk()
4151
t.AssertContains("image/png")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.