mirror of https://github.com/statping/statping
additional testing
parent
c62e26510a
commit
116b19e10d
|
@ -73,7 +73,8 @@ func LogsLineHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Write([]byte(utils.LastLine.(string)))
|
msg := utils.LastLine.(error)
|
||||||
|
w.Write([]byte(msg.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
type backups struct {
|
type backups struct {
|
||||||
|
|
|
@ -219,7 +219,6 @@ func TestViewHTTPServicesHandler(t *testing.T) {
|
||||||
Router().ServeHTTP(rr, req)
|
Router().ServeHTTP(rr, req)
|
||||||
body := rr.Body.String()
|
body := rr.Body.String()
|
||||||
assert.Equal(t, 200, rr.Code)
|
assert.Equal(t, 200, rr.Code)
|
||||||
t.Log(body)
|
|
||||||
assert.Contains(t, body, "<title>Statup | Crystal Castles - Kept Service</title>")
|
assert.Contains(t, body, "<title>Statup | Crystal Castles - Kept Service</title>")
|
||||||
assert.Contains(t, body, "Statup made with ❤️")
|
assert.Contains(t, body, "Statup made with ❤️")
|
||||||
}
|
}
|
||||||
|
@ -231,7 +230,6 @@ func TestViewTCPServicesHandler(t *testing.T) {
|
||||||
Router().ServeHTTP(rr, req)
|
Router().ServeHTTP(rr, req)
|
||||||
body := rr.Body.String()
|
body := rr.Body.String()
|
||||||
assert.Equal(t, 200, rr.Code)
|
assert.Equal(t, 200, rr.Code)
|
||||||
t.Log(body)
|
|
||||||
assert.Contains(t, body, "<title>Statup | Local Postgres Service</title>")
|
assert.Contains(t, body, "<title>Statup | Local Postgres Service</title>")
|
||||||
assert.Contains(t, body, "Statup made with ❤️")
|
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, "Awesome Status")
|
||||||
assert.Contains(t, body, "Statup made with ❤️")
|
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)
|
||||||
|
}
|
|
@ -69,11 +69,6 @@ func rotate() {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Panic(err interface{}) {
|
|
||||||
log.Printf("PANIC: %v\n", err)
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Log(level int, err interface{}) {
|
func Log(level int, err interface{}) {
|
||||||
LastLine = err
|
LastLine = err
|
||||||
switch level {
|
switch level {
|
||||||
|
|
Loading…
Reference in New Issue