{wip} tests

This commit is contained in:
2024-11-03 22:21:57 +01:00
parent 0f6cb392d6
commit a230c2aa52
6 changed files with 167 additions and 16 deletions

View File

@@ -54,12 +54,30 @@ const (
ReviewStateUnknown models.ReviewStateType = ""
)
type Gitea interface {
GetPullRequestAndReviews(org, project string, num int64) (*models.PullRequest, []*models.PullReview, error)
GetPullNotifications(since *time.Time) ([]*models.NotificationThread, error)
SetNotificationRead(notificationId int64) error
GetOrganization(orgName string) (*models.Organization, error)
GetOrganizationRepositories(orgName string) ([]*models.Repository, error)
CreateRepositoryIfNotExist(git *GitHandler, org Organization, repoName string) (*models.Repository, error)
CreatePullRequestIfNotExist(repo *models.Repository, srcId, targetId, title, body string) (*models.PullRequest, error)
RequestReviews(pr *models.PullRequest, reviewer string) ([]*models.PullReview, error)
IsReviewed(pr *models.PullRequest) (bool, error)
AddReviewComment(pr *models.PullRequest, state models.ReviewStateType, comment string) (*models.PullReview, error)
GetAssociatedPrjGitPR(pr *PullRequestWebhookEvent) (*models.PullRequest, error)
GetRepositoryFileContent(repo *models.Repository, hash, path string) ([]byte, error)
GetPullRequestFileContent(pr *models.PullRequest, path string) ([]byte, error)
GetRecentPullRequests(org, repo string) ([]*models.PullRequest, error)
GetRecentCommits(org, repo, branch string, commitNo int64) ([]*models.Commit, error)
}
type GiteaTransport struct {
transport *transport.Runtime
client *apiclient.GiteaAPI
}
func AllocateGiteaTransport(host string) *GiteaTransport {
func AllocateGiteaTransport(host string) Gitea {
var r GiteaTransport
r.transport = transport.New(host, apiclient.DefaultBasePath, [](string){"https"})