コード例 #1
0
ファイル: handlers.go プロジェクト: craigfurman/Woodhouse-CI
func (h *Handler) listJobs(w http.ResponseWriter, r *http.Request) {
	if list, err := h.jobService.AllLatestBuilds(); err == nil {
		type cell struct {
			ID     string
			Name   string
			Status string
		}

		cells := [][]cell{}
		for _, buildRow := range helpers.JobGrid(list) {
			cellRow := []cell{}
			for _, build := range buildRow {
				cellRow = append(cellRow, cell{
					ID:     build.ID,
					Name:   build.Name,
					Status: helpers.Classes(build),
				})
			}
			cells = append(cells, cellRow)
		}

		p := struct {
			BuildRows [][]cell
		}{
			BuildRows: cells,
		}
		h.renderTemplate("list_jobs", p, w)
	} else {
		h.renderErrPage("listing jobs", err, w, r)
	}
}
コード例 #2
0
	)

	build := func(i int) jobs.Build {
		return jobs.Build{Job: jobs.Job{ID: strconv.Itoa(i)}}
	}

	createList := func(n int) []jobs.Build {
		l := []jobs.Build{}
		for i := 0; i < n; i++ {
			l = append(l, build(i))
		}
		return l
	}

	JustBeforeEach(func() {
		grid = helpers.JobGrid(list)
	})

	Context("when there are no jobs", func() {
		BeforeEach(func() {
			list = createList(0)
		})

		It("returns an empty grid", func() {
			Expect(grid).To(BeEmpty())
		})
	})

	Context("when there is one job", func() {
		BeforeEach(func() {
			list = createList(1)