Example #1
0
func handleIndex() func(w http.ResponseWriter, r *http.Request) {
	return func(w http.ResponseWriter, r *http.Request) {
		data := make(map[string]interface{})
		data["Incidents"] = db.GetAllIncidents()
		rendering.RenderTemplate(w, r, "index", data)
	}
}
Example #2
0
func TestInsert(t *testing.T) {
	incidents := db.GetAllIncidents()
	if len(incidents) != 1000 {
		testFailure(t, "Save Check", 1000, len(incidents))
	}
	if incidents[0].ID != 1 {
		testFailure(t, "ID Check", 1, incidents[0].ID)
	}
	if incidents[0].Values["value"] != "Value 1" {
		testFailure(t, "Value Check", "Value 1", incidents[0].Values["value"])
	}

	incidents = db.GetIncidents(5, 100)
	if len(incidents) != 100 {
		testFailure(t, "Page Check", 100, len(incidents))
	}
	if incidents[0].ID != 401 {
		testFailure(t, "ID Check", 401, incidents[0].ID)
	}
}