Skip to content

Commit

Permalink
v1.1.16 added test for HTTPAnswerJSON()
Browse files Browse the repository at this point in the history
Signed-off-by: miguel <miguelpragier@gmail.com>
  • Loading branch information
miguelpragier committed May 8, 2020
1 parent 7a381aa commit 0503cfb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions handyhttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,23 @@ func TestHTTPJSONToStruct(t *testing.T) {
t.Errorf("Test has failed! %v", err)
}
}
func TestHTTPAnswerJSON(t *testing.T) {
const (
testName = "Forty Two"
testAge = 42
)

httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var testDummy struct {
Name string `json:"name"`
Age int `json:"age"`
}

testDummy.Name = testName
testDummy.Age = testAge

if err := HTTPAnswerJSON(w, testDummy); err != nil {
t.Error(err)
}
}))
}

0 comments on commit 0503cfb

Please sign in to comment.