Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #439 from gobuffalo/moving-action-tests-to-filetest
Browse files Browse the repository at this point in the history
Moving action generator tests to use filetest
  • Loading branch information
markbates authored May 18, 2017
2 parents a746eea + d9f8f88 commit 60dfdb6
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 239 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ RUN buffalo g actions ouch build edit
RUN buffalo d action -y ouch
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/destroy_action_all.json

RUN buffalo g actions comments show edit
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/generate_action_all.json

RUN buffalo g actions comments destroy
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/generate_action_existing.json

RUN buffalo g resource user
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/generate_resource_singular.json

RUN buffalo g resource cars
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/generate_resource_plural.json

RUN buffalo g actions users create --skip-template
RUN filetest -c $GOPATH/src/github.com/gobuffalo/buffalo/buffalo/cmd/filetests/generate_action_skip_template.json

Expand Down
22 changes: 22 additions & 0 deletions buffalo/cmd/filetests/generate_action_all.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[{
"path": "actions/comments.go",
"contains": [
"func CommentsShow(c buffalo.Context) error {",
"func CommentsEdit(c buffalo.Context) error {",
"comments/edit.html",
"comments/show.html"
]
},
{
"path": "actions/app.go",
"contains": [
"app.GET(\"/comments/show\", CommentsShow)",
"app.GET(\"/comments/edit\", CommentsEdit)"
]
},
{
"path": "templates/comments/show.html",
"contains": [
"<h1>Comments#Show</h1>"
]
}]
19 changes: 19 additions & 0 deletions buffalo/cmd/filetests/generate_action_existing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[{
"path": "actions/comments.go",
"contains": [
"func CommentsShow(c buffalo.Context) error {",
"func CommentsEdit(c buffalo.Context) error {",
"func CommentsDestroy(c buffalo.Context) error {",
"comments/edit.html",
"comments/destroy.html",
"comments/show.html"
]
},
{
"path": "actions/app.go",
"contains": [
"app.GET(\"/comments/destroy\", CommentsDestroy)",
"app.GET(\"/comments/edit\", CommentsEdit)",
"app.GET(\"/comments/show\", CommentsShow)"
]
}]
22 changes: 22 additions & 0 deletions buffalo/cmd/filetests/generate_resource_plural.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[{
"path": "actions/cars.go",
"contains": [
"func (v CarsResource) List(c buffalo.Context) error {",
"func (v CarsResource) Destroy(c buffalo.Context) error {",
"type CarsResource struct {"
]
},
{
"path": "actions/app.go",
"contains": [
"app.Resource(\"/cars\", CarsResource{&buffalo.BaseResource{}})"
]
},
{
"path": "actions/cars_test.go",
"contains": [
"func (as *ActionSuite) Test_CarsResource_List",
"func (as *ActionSuite) Test_CarsResource_Show",
"func (as *ActionSuite) Test_CarsResource_Create"
]
}]
22 changes: 22 additions & 0 deletions buffalo/cmd/filetests/generate_resource_singular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[{
"path": "actions/users.go",
"contains": [
"func (v UsersResource) List(c buffalo.Context) error {",
"func (v UsersResource) Destroy(c buffalo.Context) error {",
"type UsersResource struct {"
]
},
{
"path": "actions/app.go",
"contains": [
"app.Resource(\"/users\", UsersResource{&buffalo.BaseResource{}})"
]
},
{
"path": "actions/users_test.go",
"contains": [
"func (as *ActionSuite) Test_UsersResource_List",
"func (as *ActionSuite) Test_UsersResource_Show",
"func (as *ActionSuite) Test_UsersResource_Create"
]
}]
168 changes: 0 additions & 168 deletions buffalo/cmd/generate/action_test.go

This file was deleted.

69 changes: 0 additions & 69 deletions buffalo/cmd/generate/resource_test.go

This file was deleted.

7 changes: 5 additions & 2 deletions generators/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ func TestAppendRoute(t *testing.T) {

tmpDir := os.TempDir()
packagePath := filepath.Join(tmpDir, "src", "sample")
os.MkdirAll(packagePath, 0755)
err := os.MkdirAll(packagePath, 0644)
println(err)

os.Chdir(packagePath)

const shortAppFileExample = `package actions
Expand Down Expand Up @@ -46,7 +48,8 @@ func App() *buffalo.App {
return app
}`

ioutil.WriteFile(filepath.Join(packagePath, "actions", "app.go"), []byte(shortAppFileExample), 0755)
os.MkdirAll("actions", 0644)
ioutil.WriteFile(filepath.Join(packagePath, "actions", "app.go"), []byte(shortAppFileExample), 0644)

AddRoute("GET", "/new/route", "UserCoolHandler")

Expand Down

0 comments on commit 60dfdb6

Please sign in to comment.