This commit is contained in:
Adam Majer 2024-12-04 08:55:40 +01:00
parent 0c866e8f89
commit a025328fef
3 changed files with 38 additions and 8 deletions

View File

@ -63,15 +63,9 @@ prjMaintainer:
}
func CheckIfMaintainersApproved(gitea GiteaMaintainershipInterface, config common.AutogitConfig, prjGitPRNumber int64) (bool, error) {
gitea.GetPullRequestAndReviews(config.Organization, config.GitProjectName, prjGitPRNumber)
data, _ := gitea.FetchMaintainershipFile(config.Organization, config.GitProjectName, config.Branch)
parseMaintainershipData(data)
/*
pr, reviews, _ := gitea.GetPullRequestAndReviews(config.Organization, config.GitProjectName, prjGitPRNumber)
data, _ := gitea.FetchMaintainershipFile(config.Organization, config.GitProjectName, config.Branch)
maintainers, _ := parseMaintainershipData(data)
*/
return false, nil
}

View File

@ -1,5 +1,32 @@
package main
import (
"src.opensuse.org/autogits/common"
"src.opensuse.org/autogits/common/gitea-generated/models"
)
//go:generate mockgen -source=pr.go -destination=mock/pr.go -typed
type GiteaPRInterface interface {
GetAssociatedPrjGitPR(org, repo string, id int) (*models.PullRequest, error)
GetAssociatedPRs(org, repo string, id int) ([]*models.PullRequest, error)
}
type PRInterface struct {
gitea common.Gitea
}
func AllocatePRInterface(gitea common.Gitea) GiteaPRInterface {
return &PRInterface{
gitea: gitea,
}
}
func (s *PRInterface) GetAssociatedPrjGitPR(org, repo string, id int) (*models.PullRequest, error) {
return nil, nil
}
func (s *PRInterface) GetAssociatedPRs(org, repo string, id int) ([]*models.PullRequest, error) {
return nil, nil
}

View File

@ -1,10 +1,19 @@
package main
import "testing"
import (
"testing"
"go.uber.org/mock/gomock"
"src.opensuse.org/autogits/common/gitea-generated/models"
mock_main "src.opensuse.org/workflow-pr/mock"
)
func TestPR(t *testing.T) {
t.Run("Test simple PR to PrjGit checkout", func(t *testing.T) {
ctl := gomock.NewController(t)
pr := mock_main.NewMockGiteaPRInterface(ctl)
pr.EXPECT().GetPR("foo", "bar", 22).Return(&models.PullRequest{}, nil)
})
}