This commit is contained in:
Bel LaPointe
2024-02-20 08:23:37 -07:00
parent 4241b83721
commit a1d9e30030
2 changed files with 85 additions and 10 deletions

View File

@@ -8,7 +8,9 @@ import (
)
func TestRunHTTP(t *testing.T) {
cfg := Config{}
cfg := Config{
fsDB: t.TempDir(),
}
h := cfg.NewHandler()
@@ -53,8 +55,8 @@ func TestRunHTTP(t *testing.T) {
}
})
t.Run("/api/v1/question", func(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/api/v1/question", nil)
t.Run("/api/v1/questions/0", func(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/api/v1/questions/0", nil)
r.SetBasicAuth("b", "b")
w := httptest.NewRecorder()
t.Logf("%s %s", r.Method, r.URL)
@@ -66,8 +68,21 @@ func TestRunHTTP(t *testing.T) {
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)
t.Run("/api/v1/questions", func(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/api/v1/questions", 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/answers", func(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/api/v1/answers", nil)
r.SetBasicAuth("b", "b")
w := httptest.NewRecorder()
t.Logf("%s %s", r.Method, r.URL)