示例#1
0
func TestDeleteRepo(t *testing.T) {
	Setup()
	defer Teardown()

	if err := database.DeleteRepo(1); err != nil {
		t.Error(err)
	}

	// try to get the deleted row
	_, err := database.GetRepo(1)
	if err == nil {
		t.Fail()
	}
}
示例#2
0
文件: repos.go 项目: ninholic/drone
// Deletes a specific repository.
func RepoDelete(w http.ResponseWriter, r *http.Request, u *User, repo *Repo) error {
	// the user must confirm their password before deleting
	password := r.FormValue("password")
	if err := u.ComparePassword(password); err != nil {
		return RenderError(w, err, http.StatusBadRequest)
	}

	// delete the repo
	if err := database.DeleteRepo(repo.ID); err != nil {
		return err
	}

	http.Redirect(w, r, "/dashboard", http.StatusSeeOther)
	return nil
}