gitea

package
v0.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SuccessRegexp = regexp.MustCompile(`.*Pipelines as Code CI.*has.*successfully.*validated your commit.*`)

SuccessRegexp matches a successful Pipelines as Code CI comment, accounting for possible HTML tags.

Functions

func AddLabelToIssue added in v0.32.0

func AddLabelToIssue(t *testing.T, topt *TestOpts, label string)

func AssertConcurrencyRespected added in v0.50.0

func AssertConcurrencyRespected(ctx context.Context, t *testing.T, topts *TestOpts, limit int)

AssertConcurrencyRespected checks that the repository never ran more than limit PipelineRuns at once.

Waiting for every PipelineRun to succeed, which is all the concurrency tests used to do, passes just as happily when the queue ignores the limit and runs them all at the same time. This is the assertion that tests the queue.

func CheckIfPipelineRunsCancelled added in v0.15.0

func CheckIfPipelineRunsCancelled(t *testing.T, topts *TestOpts)

func CreateAccess

func CreateAccess(topts *TestOpts, touser, accessMode string) error

func CreateCRD

func CreateCRD(ctx context.Context, topts *TestOpts, spec v1alpha1.RepositorySpec, isGlobal bool) error

func CreateForkPullRequest

func CreateForkPullRequest(t *testing.T, topts *TestOpts, secondcnx pgitea.Provider, accessMode string) *forgejo.PullRequest

func CreateGiteaRepo

func CreateGiteaRepo(giteaClient *forgejo.Client, user, name, defaultBranch, hookURL, webhookSecret string, onOrg bool, logger *zap.SugaredLogger) (*forgejo.Repository, error)

func CreateGiteaUser

func CreateGiteaUser(giteaClient *forgejo.Client, username, password string) (*forgejo.User, error)

func CreateGiteaUserSecondCnx added in v0.20.0

func CreateGiteaUserSecondCnx(topts *TestOpts, username, password string) (pgitea.Provider, *forgejo.User, error)

CreateGiteaUserSecondCnx creates a new user and a new provider for this user.

func CreateProvider

func CreateProvider(ctx context.Context, giteaURL, user, password string) (gitea.Provider, error)

func CreateTeam added in v0.20.0

func CreateTeam(topts *TestOpts, orgName, teamName string) (*forgejo.Team, error)

func CreateToken added in v0.20.0

func CreateToken(topts *TestOpts) (string, error)

CreateToken creates gitea token with all scopes. It creates the token for the authenticated admin user rather than the org, because Forgejo 13+ doesn't allow org tokens to list org teams.

func GetGiteaRepo added in v0.23.0

func GetGiteaRepo(giteaClient *forgejo.Client, user, name string, _ *zap.SugaredLogger) (*forgejo.Repository, error)

func GetStandardParams added in v0.21.0

func GetStandardParams(t *testing.T, topts *TestOpts, eventType string) (repoURL, sourceURL, sourceBranch, targetBranch string)

func InitGitRepo

func InitGitRepo(t *testing.T) (string, func())

func MakeRequest

func MakeRequest(ctx context.Context, httpClient http.Client, url, username, password string) (*http.Response, error)

func NewPR added in v0.23.0

func NewPR(t *testing.T, topts *TestOpts) func()

func PostCommentOnPullRequest

func PostCommentOnPullRequest(t *testing.T, topt *TestOpts, body string)

func PushFilesToRefAPI

func PushFilesToRefAPI(t *testing.T, topts *TestOpts, entries map[string]string) (string, error)

PushFilesToRefAPI will push files to a given ref via API.

func PushToPullRequest added in v0.21.0

func PushToPullRequest(t *testing.T, topts *TestOpts, secondcnx pgitea.Provider, command string)

func RemoveCommentMatching added in v0.20.0

func RemoveCommentMatching(topts *TestOpts, commentString *regexp.Regexp) error

func Setup

func TearDown

func TearDown(ctx context.Context, t *testing.T, topts *TestOpts)

func TestPR

func TestPR(t *testing.T, topts *TestOpts) (context.Context, func())

TestPR will test the pull request event and grab comments from the PR.

func VerifyConcurrency added in v0.28.0

func VerifyConcurrency(t *testing.T, topts *TestOpts, globalRepoConcurrencyLimit *int)

VerifyConcurrency runs a PR against a global repository concurrency limit and checks the effective limit was respected. The local limit wins when both are set, which is what the caller passes as effectiveLimit.

func WaitForPullRequestCommentGoldenMatch added in v0.39.0

func WaitForPullRequestCommentGoldenMatch(t *testing.T, topts *TestOpts, goldenFile string)

WaitForPullRequestCommentGoldenMatch will wait for a comment matching exactly (golden style) the content.

func WaitForPullRequestCommentMatch

func WaitForPullRequestCommentMatch(t *testing.T, topts *TestOpts)

func WaitForSecretDeletion added in v0.14.3

func WaitForSecretDeletion(t *testing.T, topts *TestOpts, _ string)

func WaitForStatus

func WaitForStatus(t *testing.T, topts *TestOpts, ref, forcontext string, onlylatest bool)

Types

type TestOpts

type TestOpts struct {
	TargetRepoName        string
	StatusOnlyLatest      bool
	OnOrg                 bool
	NoPullRequestCreation bool
	SkipEventsCheck       bool
	TargetNS              string
	TargetEvent           string
	Settings              *v1alpha1.Settings
	Regexp                *regexp.Regexp
	YAMLFiles             map[string]string
	ExtraArgs             map[string]string
	RepoCRParams          *[]v1alpha1.Params
	GlobalRepoCRParams    *[]v1alpha1.Params
	CheckForStatus        string
	TargetRefName         string
	CheckForNumberStatus  int
	ConcurrencyLimit      *int
	ParamsRun             *params.Run
	GiteaCNX              pgitea.Provider
	Opts                  options.E2E
	PullRequest           *forgejo.PullRequest
	DefaultBranch         string
	GitCloneURL           string
	GitHTMLURL            string
	GiteaAPIURL           string
	GiteaPassword         string
	ExpectEvents          bool
	InternalGiteaURL      string
	Token                 string
	SHA                   string
	FileChanges           []scm.FileChange
	CreateSecret          []corev1.Secret
	ProviderType          string // defaults to "forgejo" if empty
	SecondUserName        string
}

type Timelines

type Timelines []struct {
	Body string `json:"body"`
}

func GetIssueTimeline

func GetIssueTimeline(ctx context.Context, topts *TestOpts) (Timelines, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL