Skip to content

Commit 3150afb

Browse files
committed
fix handler.Initialize calls
1 parent 420cfad commit 3150afb

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

app/handler/admin_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"testing"
1212
"time"
1313

14-
"github.com/dingoblog/dingo/app/model"
1514
"github.com/dinever/golf"
15+
"github.com/dingoblog/dingo/app/model"
1616
. "github.com/smartystreets/goconvey/convey"
1717
)
1818

@@ -22,7 +22,8 @@ func authenticatedContext(form url.Values, method, path string) *golf.Context {
2222
ctx.App.ServeHTTP(ctx.Response, ctx.Request)
2323
rec := ctx.Response.(*httptest.ResponseRecorder)
2424
w := httptest.NewRecorder()
25-
app := InitTestApp()
25+
app := golf.New()
26+
app = InitTestApp(app)
2627
req := makeTestHTTPRequest(strings.NewReader(form.Encode()), method, path)
2728
req.Header = http.Header{"Cookie": rec.HeaderMap["Set-Cookie"]}
2829
req.PostForm = form

app/handler/auth_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/dingoblog/dingo/app/model"
1312
"github.com/dinever/golf"
13+
"github.com/dingoblog/dingo/app/model"
1414
. "github.com/smartystreets/goconvey/convey"
1515
)
1616

@@ -155,7 +155,8 @@ func TestUserLogInWithCorrectInformation(t *testing.T) {
155155
Convey("Visit admin dashboard", func() {
156156

157157
w := httptest.NewRecorder()
158-
app := Initialize()
158+
app := golf.New()
159+
app = Initialize(app)
159160

160161
req := makeTestHTTPRequest(nil, "GET", "/admin/")
161162
req.Header = http.Header{"Cookie": rec.HeaderMap["Set-Cookie"]}

app/handler/setup_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const name = "Shawn Ding"
1515
const email = "[email protected]"
1616
const password = "passwordfortest"
1717

18-
func InitTestApp() *golf.Application {
19-
app := Initialize()
18+
func InitTestApp(app *golf.Application) *golf.Application {
19+
app = Initialize(app)
2020

2121
app.View.SetTemplateLoader("base", "view")
2222
app.View.SetTemplateLoader("admin", filepath.Join("..", "..", "view", "admin"))
@@ -34,7 +34,8 @@ func makeTestHTTPRequest(body io.Reader, method, url string) *http.Request {
3434

3535
func mockSignUpPostRequest(email, name, password, rePassword string) *golf.Context {
3636
w := httptest.NewRecorder()
37-
Initialize()
37+
app := golf.New()
38+
app = Initialize(app)
3839

3940
form := url.Values{}
4041
form.Add("email", email)
@@ -49,7 +50,8 @@ func mockSignUpPostRequest(email, name, password, rePassword string) *golf.Conte
4950

5051
func mockContext(form url.Values, method, path string) *golf.Context {
5152
w := httptest.NewRecorder()
52-
Initialize()
53+
app := golf.New()
54+
app = Initialize(app)
5355

5456
r := makeTestHTTPRequest(strings.NewReader(form.Encode()), method, path)
5557
r.PostForm = form
@@ -58,7 +60,8 @@ func mockContext(form url.Values, method, path string) *golf.Context {
5860

5961
func mockLogInPostContext() *golf.Context {
6062
w := httptest.NewRecorder()
61-
Initialize()
63+
app := golf.New()
64+
app = Initialize(app)
6265

6366
form := url.Values{}
6467
form.Add("email", email)

0 commit comments

Comments
 (0)