1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-23 00:22:19 +00:00

More coverage on web package

This commit is contained in:
Yohann D'ANELLO 2020-09-30 16:09:25 +02:00
parent ac40d81e98
commit ea860a0790
2 changed files with 17 additions and 1 deletions

View File

@ -36,7 +36,7 @@ func viewerPostHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.Write(jsonDesc) _, _ = w.Write(jsonDesc)
// Increment monitoring // Increment monitoring
monitoring.WebSessions.Inc() monitoring.WebSessions.Inc()

View File

@ -19,4 +19,20 @@ func TestViewerPageGET(t *testing.T) {
if w.Code != http.StatusOK { if w.Code != http.StatusOK {
t.Errorf("Viewer page returned %v != %v on GET", w.Code, http.StatusOK) t.Errorf("Viewer page returned %v != %v on GET", w.Code, http.StatusOK)
} }
// Test GET request on not found page
r, _ = http.NewRequest("GET", "", nil)
w = httptest.NewRecorder()
http.HandlerFunc(viewerHandler).ServeHTTP(w, r)
if w.Code != http.StatusNotFound {
t.Errorf("Viewer page returned %v != %v on GET", w.Code, http.StatusOK)
}
// Test GET request on statistics page
r, _ = http.NewRequest("GET", "/", nil)
w = httptest.NewRecorder()
http.HandlerFunc(statisticsHandler).ServeHTTP(w, r)
if w.Code != http.StatusOK {
t.Errorf("Viewer page returned %v != %v on GET", w.Code, http.StatusOK)
}
} }