Skip to content

Commit

Permalink
Tests #3
Browse files Browse the repository at this point in the history
  • Loading branch information
joegasewicz committed May 1, 2023
1 parent 00d15b1 commit fc75686
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ app.Handle("/public/", http.StripPrefix("/public/", publicFiles))
# Testing
Gomek provides a testing utility that returns a regular `HandlerFunc`
- `gomek.CreateTestHandler`
```go
c := Config{}
mockApp := NewTestApp(c)
Expand All @@ -208,7 +209,7 @@ mockApp.Start()

notice := Notice{}

handler := CreateTestHandler(mockApp, notice.Post)
handler := gomek.CreateTestHandler(mockApp, notice.Post)

req := httptest.NewRequest(http.MethodPost, "/blogs", nil)
w := httptest.NewRecorder()
Expand All @@ -218,7 +219,7 @@ resp := w.Result()
defer resp.Body.Close()
data, err := io.ReadAll(resp.Body)
if err != nil {
t.Errorf("Error: %v", err)
t.Errorf("Error: %v", err)
}
expected := `{"name":"Joe"}`
if string(data) != expected {
Expand Down

0 comments on commit fc75686

Please sign in to comment.