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 1c9c297 commit 446a029Copy full SHA for 446a029
kadai4/main_test.go
@@ -1,6 +1,7 @@
1
package main
2
3
import (
4
+ "encoding/json"
5
"io/ioutil"
6
"net/http"
7
"net/http/httptest"
@@ -24,8 +25,14 @@ func TestHandler(t *testing.T) {
24
25
t.Fatal("unexpected error")
26
}
27
- const expected = `{"msg":"大吉"}`
28
- if s := string(b); s != expected {
29
- t.Fatalf("unexpected response: %s", s)
+ res := &Response{}
+ // TODO: 実行時のseeder設定により、大吉しか返ってないので、テストが通る
30
+ const expected = "大吉"
31
+ if err := json.Unmarshal(b, res); err != nil {
32
+ t.Fatalf("JSON unmarshall error: %v", err)
33
+ }
34
+
35
+ if res.Msg != string(expected) {
36
+ t.Fatalf("unexpected response: %s", res.Msg)
37
38
0 commit comments