We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7a381aa commit 0503cfbCopy full SHA for 0503cfb
handyhttp_test.go
@@ -134,3 +134,23 @@ func TestHTTPJSONToStruct(t *testing.T) {
134
t.Errorf("Test has failed! %v", err)
135
}
136
137
+func TestHTTPAnswerJSON(t *testing.T) {
138
+ const (
139
+ testName = "Forty Two"
140
+ testAge = 42
141
+ )
142
+
143
+ httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
144
+ var testDummy struct {
145
+ Name string `json:"name"`
146
+ Age int `json:"age"`
147
+ }
148
149
+ testDummy.Name = testName
150
+ testDummy.Age = testAge
151
152
+ if err := HTTPAnswerJSON(w, testDummy); err != nil {
153
+ t.Error(err)
154
155
+ }))
156
+}
0 commit comments