Пример #1
0
// JobsHome renders jobs home page
//
//
//		Method           GET
//
//		Route            /jobs/
//
//		Restrictions     None
//
// 		Template         base/jobs.html
func JobsHome(ctx *echo.Context) error {
	jobs, err := query.GetLatestJobs()
	if err != nil {
		utils.SetData(ctx, "Message", tmpl.NotFoundMessage)
		return ctx.Render(http.StatusNotFound, tmpl.ErrNotFoundTpl, utils.GetData(ctx))

	}
	utils.SetData(ctx, settings.JobsListKey, jobs)
	utils.SetData(ctx, settings.PageTitleKey, "jobs")
	return ctx.Render(http.StatusOK, tmpl.BaseJobsHomeTpl, utils.GetData(ctx))
}
Пример #2
0
func TestJobsView(t *testing.T) {
	view := "%s/jobs/view/%d"
	jobs, err := query.GetLatestJobs()
	if err != nil {
		t.Error(err)
	}
	for _, job := range jobs {
		viewURL := fmt.Sprintf(view, ts.URL, job.ID)
		resp, err := client.Get(viewURL)
		if err != nil {
			t.Error(err)
		}
		defer resp.Body.Close()
		if resp.StatusCode != http.StatusOK {
			t.Errorf("expected %d got %d", http.StatusOK, resp.StatusCode)
		}
	}
}