From a025328fef25f5c7836a14fbe315b72e95385d8afe75b51625659499a915f237 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Wed, 4 Dec 2024 08:55:40 +0100 Subject: [PATCH] wip --- workflow-pr/maintainership.go | 6 ------ workflow-pr/pr.go | 27 +++++++++++++++++++++++++++ workflow-pr/pr_test.go | 13 +++++++++++-- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/workflow-pr/maintainership.go b/workflow-pr/maintainership.go index 5ff42c5..ead0473 100644 --- a/workflow-pr/maintainership.go +++ b/workflow-pr/maintainership.go @@ -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 } diff --git a/workflow-pr/pr.go b/workflow-pr/pr.go index cd57c71..1ba36b4 100644 --- a/workflow-pr/pr.go +++ b/workflow-pr/pr.go @@ -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 +} diff --git a/workflow-pr/pr_test.go b/workflow-pr/pr_test.go index cad7c9b..dd97f40 100644 --- a/workflow-pr/pr_test.go +++ b/workflow-pr/pr_test.go @@ -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) }) }