additional testing

pull/44/merge
Hunter Long 2018-07-26 23:32:04 -07:00
parent c62e26510a
commit 116b19e10d
4 changed files with 22 additions and 9 deletions

View File

@ -73,7 +73,8 @@ func LogsLineHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Write([]byte(utils.LastLine.(string)))
msg := utils.LastLine.(error)
w.Write([]byte(msg.Error()))
}
type backups struct {

View File

@ -219,7 +219,6 @@ func TestViewHTTPServicesHandler(t *testing.T) {
Router().ServeHTTP(rr, req)
body := rr.Body.String()
assert.Equal(t, 200, rr.Code)
t.Log(body)
assert.Contains(t, body, "<title>Statup | Crystal Castles - Kept Service</title>")
assert.Contains(t, body, "Statup made with ❤️")
}
@ -231,7 +230,6 @@ func TestViewTCPServicesHandler(t *testing.T) {
Router().ServeHTTP(rr, req)
body := rr.Body.String()
assert.Equal(t, 200, rr.Code)
t.Log(body)
assert.Contains(t, body, "<title>Statup | Local Postgres Service</title>")
assert.Contains(t, body, "Statup made with ❤️")
}
@ -303,3 +301,22 @@ func TestViewSettingsHandler(t *testing.T) {
assert.Contains(t, body, "Awesome Status")
assert.Contains(t, body, "Statup made with ❤️")
}
func TestPrometheusHandler(t *testing.T) {
req, err := http.NewRequest("GET", "/metrics", nil)
req.Header.Set("Authorization", core.CoreApp.ApiSecret)
assert.Nil(t, err)
rr := httptest.NewRecorder()
Router().ServeHTTP(rr, req)
body := rr.Body.String()
assert.Equal(t, 200, rr.Code)
assert.Contains(t, body, "statup_total_services 7")
}
func TestLogoutHandler(t *testing.T) {
req, err := http.NewRequest("GET", "/logout", nil)
assert.Nil(t, err)
rr := httptest.NewRecorder()
Router().ServeHTTP(rr, req)
assert.Equal(t, 303, rr.Code)
}

View File

@ -59,7 +59,7 @@ func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
description := r.PostForm.Get("description")
domain := r.PostForm.Get("domain")
email := r.PostForm.Get("email")
config := &core.DbConfig{
dbConn,
dbHost,

View File

@ -69,11 +69,6 @@ func rotate() {
}()
}
func Panic(err interface{}) {
log.Printf("PANIC: %v\n", err)
panic(err)
}
func Log(level int, err interface{}) {
LastLine = err
switch level {