tdd ish
parent
9686d1c7dd
commit
4241b83721
|
|
@ -138,5 +138,20 @@ func (h Handler) handle(session Session, w http.ResponseWriter, r *http.Request)
|
||||||
http.FileServer(public).ServeHTTP(w, r)
|
http.FileServer(public).ServeHTTP(w, r)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
switch r.URL.Path {
|
||||||
|
case "/api/v1/question":
|
||||||
|
return h.handleAPIV1Question(session, w, r)
|
||||||
|
case "/api/v1/answer":
|
||||||
|
return h.handleAPIV1Answer(session, w, r)
|
||||||
|
}
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h Handler) handleAPIV1Question(session Session, w http.ResponseWriter, r *http.Request) error {
|
||||||
|
return errors.New("not impl")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h Handler) handleAPIV1Answer(session Session, w http.ResponseWriter, r *http.Request) error {
|
||||||
return errors.New("not impl")
|
return errors.New("not impl")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,44 @@ func TestRunHTTP(t *testing.T) {
|
||||||
t.Errorf("%s", w.Body.Bytes())
|
t.Errorf("%s", w.Body.Bytes())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("/api/notfound", func(t *testing.T) {
|
||||||
|
r := httptest.NewRequest(http.MethodGet, "/api/notfound", nil)
|
||||||
|
r.SetBasicAuth("b", "b")
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
t.Logf("%s %s", r.Method, r.URL)
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
t.Logf("(%d) %s", w.Code, w.Body.Bytes())
|
||||||
|
if w.Code != http.StatusNotFound {
|
||||||
|
t.Error(w.Code)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("/api/v1/question", func(t *testing.T) {
|
||||||
|
r := httptest.NewRequest(http.MethodGet, "/api/v1/question", nil)
|
||||||
|
r.SetBasicAuth("b", "b")
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
t.Logf("%s %s", r.Method, r.URL)
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
t.Logf("(%d) %s", w.Code, w.Body.Bytes())
|
||||||
|
if w.Code != http.StatusNotFound {
|
||||||
|
t.Error(w.Code)
|
||||||
|
}
|
||||||
|
t.Errorf("not impl: %s", w.Body.Bytes())
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("/api/v1/answer", func(t *testing.T) {
|
||||||
|
r := httptest.NewRequest(http.MethodGet, "/api/v1/answer", nil)
|
||||||
|
r.SetBasicAuth("b", "b")
|
||||||
|
w := httptest.NewRecorder()
|
||||||
|
t.Logf("%s %s", r.Method, r.URL)
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
t.Logf("(%d) %s", w.Code, w.Body.Bytes())
|
||||||
|
if w.Code != http.StatusNotFound {
|
||||||
|
t.Error(w.Code)
|
||||||
|
}
|
||||||
|
t.Errorf("not impl: %s", w.Body.Bytes())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPublic(t *testing.T) {
|
func TestPublic(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue