Пример #1
0
// Returns the combined stdout / stderr for an individual Build.
func BuildStatus(w http.ResponseWriter, r *http.Request, repo *Repo) error {
	branch := r.FormValue("branch")
	if branch == "" {
		branch = "master"
	}

	hash := r.FormValue(":commit")
	labl := r.FormValue(":label")

	// get the commit from the database
	commit, err := database.GetCommitBranchHash(branch, hash, repo.ID)
	if err != nil {
		return err
	}

	// get the build from the database
	build, err := database.GetBuildSlug(labl, commit.ID)
	if err != nil {
		return err
	}

	build_result := BuildResult{build.Status}

	return RenderJson(w, build_result)
}
Пример #2
0
// Returns the combined stdout / stderr for an individual Build.
func BuildOut(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error {
	hash := r.FormValue(":commit")
	labl := r.FormValue(":label")

	// get the commit from the database
	commit, err := database.GetCommitHash(hash, repo.ID)
	if err != nil {
		return err
	}

	// get the build from the database
	build, err := database.GetBuildSlug(labl, commit.ID)
	if err != nil {
		return err
	}

	return RenderText(w, build.Stdout, http.StatusOK)
}
Пример #3
0
func TestGetBuildSlug(t *testing.T) {
	Setup()
	defer Teardown()

	build, err := database.GetBuildSlug("node_0.10", 1)
	if err != nil {
		t.Error(err)
	}

	if build.ID != 1 {
		t.Errorf("Exepected ID %d, got %d", 1, build.ID)
	}

	if build.Slug != "node_0.10" {
		t.Errorf("Exepected Slug %s, got %s", "node_0.10", build.Slug)
	}

	if build.Status != "Success" {
		t.Errorf("Exepected Status %s, got %s", "Success", build.Status)
	}
}