From c1bb3c84bc3b605f00d0ce6d1242dfba739c9e4a Mon Sep 17 00:00:00 2001 From: 178inaba <178inaba@users.noreply.github.com> Date: Fri, 21 Apr 2017 02:29:22 +0900 Subject: [PATCH] Add fail test cover to TestRegisterApp --- apps_test.go | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/apps_test.go b/apps_test.go index d88ff4b..bab20bf 100644 --- a/apps_test.go +++ b/apps_test.go @@ -10,24 +10,53 @@ import ( ) func TestRegisterApp(t *testing.T) { + isNotJSON := true ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return - } - if r.URL.Path != "/api/v1/apps" { + } else if r.URL.Path != "/api/v1/apps" { http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) return - } - if r.FormValue("redirect_uris") != "urn:ietf:wg:oauth:2.0:oob" { + } else if r.FormValue("redirect_uris") != "urn:ietf:wg:oauth:2.0:oob" { http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) return + } else if isNotJSON { + isNotJSON = false + fmt.Fprintln(w, `