move maintainership to common/
This commit is contained in:
parent
205741dde1
commit
4dd864c7b6
@ -1,10 +1,12 @@
|
|||||||
package common
|
package common_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"src.opensuse.org/autogits/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStringScanner(s string) *bufio.Scanner {
|
func newStringScanner(s string) *bufio.Scanner {
|
||||||
@ -15,25 +17,25 @@ func TestAssociatedPRScanner(t *testing.T) {
|
|||||||
testTable := []struct {
|
testTable := []struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
prs []BasicPR
|
prs []common.BasicPR
|
||||||
desc string
|
desc string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"No PRs",
|
"No PRs",
|
||||||
"",
|
"",
|
||||||
[]BasicPR{},
|
[]common.BasicPR{},
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Single PRs",
|
"Single PRs",
|
||||||
"Some header of the issue\n\nFollowed by some description\n\nPR: test/foo#4\n",
|
"Some header of the issue\n\nFollowed by some description\n\nPR: test/foo#4\n",
|
||||||
[]BasicPR{{Org: "test", Repo: "foo", Num: 4}},
|
[]common.BasicPR{{Org: "test", Repo: "foo", Num: 4}},
|
||||||
"Some header of the issue\n\nFollowed by some description",
|
"Some header of the issue\n\nFollowed by some description",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Multiple PRs",
|
"Multiple PRs",
|
||||||
"Some header of the issue\n\nFollowed by some description\nPR: test/foo#4\n\nPR: test/goo#5\n",
|
"Some header of the issue\n\nFollowed by some description\nPR: test/foo#4\n\nPR: test/goo#5\n",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{Org: "test", Repo: "foo", Num: 4},
|
{Org: "test", Repo: "foo", Num: 4},
|
||||||
{Org: "test", Repo: "goo", Num: 5},
|
{Org: "test", Repo: "goo", Num: 5},
|
||||||
},
|
},
|
||||||
@ -42,7 +44,7 @@ func TestAssociatedPRScanner(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"Multiple PRs with whitespace",
|
"Multiple PRs with whitespace",
|
||||||
"Some header of the issue\n\n\tPR: test/goo#5\n\n Followed by some description\n \t PR: test/foo#4\n",
|
"Some header of the issue\n\n\tPR: test/goo#5\n\n Followed by some description\n \t PR: test/foo#4\n",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{Org: "test", Repo: "foo", Num: 4},
|
{Org: "test", Repo: "foo", Num: 4},
|
||||||
{Org: "test", Repo: "goo", Num: 5},
|
{Org: "test", Repo: "goo", Num: 5},
|
||||||
},
|
},
|
||||||
@ -53,7 +55,7 @@ func TestAssociatedPRScanner(t *testing.T) {
|
|||||||
"Some header of the issue\n\n\n\t PR: foobar#5 \n\t PR: rd/goo5 \n\t PR: test/#5 \n" +
|
"Some header of the issue\n\n\n\t PR: foobar#5 \n\t PR: rd/goo5 \n\t PR: test/#5 \n" +
|
||||||
"\t PR: /goo#5 \n\t PR: test/goo# \n\t PR: test / goo # 10 \n\tPR: test/gool# 10 \n" +
|
"\t PR: /goo#5 \n\t PR: test/goo# \n\t PR: test / goo # 10 \n\tPR: test/gool# 10 \n" +
|
||||||
"\t PR: test/goo#5 \n\t\n Followed by some description\n\t PR: test/foo#4 \n\t\n\n",
|
"\t PR: test/goo#5 \n\t\n Followed by some description\n\t PR: test/foo#4 \n\t\n\n",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{
|
{
|
||||||
Org: "test",
|
Org: "test",
|
||||||
Repo: "foo",
|
Repo: "foo",
|
||||||
@ -73,7 +75,7 @@ func TestAssociatedPRScanner(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range testTable {
|
for _, test := range testTable {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
desc, prs := ExtractDescriptionAndPRs(newStringScanner(test.input))
|
desc, prs := common.ExtractDescriptionAndPRs(newStringScanner(test.input))
|
||||||
if len(prs) != len(test.prs) {
|
if len(prs) != len(test.prs) {
|
||||||
t.Error("Unexpected length:", len(prs), "expected:", len(test.prs))
|
t.Error("Unexpected length:", len(prs), "expected:", len(test.prs))
|
||||||
return
|
return
|
||||||
@ -96,13 +98,13 @@ func TestAppendingPRsToDescription(t *testing.T) {
|
|||||||
testTable := []struct {
|
testTable := []struct {
|
||||||
name string
|
name string
|
||||||
desc string
|
desc string
|
||||||
PRs []BasicPR
|
PRs []common.BasicPR
|
||||||
output string
|
output string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"Append single PR to end of description",
|
"Append single PR to end of description",
|
||||||
"something",
|
"something",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{Org: "a", Repo: "b", Num: 100},
|
{Org: "a", Repo: "b", Num: 100},
|
||||||
},
|
},
|
||||||
"something\n\nPR: a/b#100",
|
"something\n\nPR: a/b#100",
|
||||||
@ -110,7 +112,7 @@ func TestAppendingPRsToDescription(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"Append multiple PR to end of description",
|
"Append multiple PR to end of description",
|
||||||
"something",
|
"something",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{Org: "a1", Repo: "b", Num: 100},
|
{Org: "a1", Repo: "b", Num: 100},
|
||||||
{Org: "a1", Repo: "c", Num: 100},
|
{Org: "a1", Repo: "c", Num: 100},
|
||||||
{Org: "a1", Repo: "c", Num: 101},
|
{Org: "a1", Repo: "c", Num: 101},
|
||||||
@ -122,7 +124,7 @@ func TestAppendingPRsToDescription(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"Append multiple sorted PR to end of description and remove dups",
|
"Append multiple sorted PR to end of description and remove dups",
|
||||||
"something",
|
"something",
|
||||||
[]BasicPR{
|
[]common.BasicPR{
|
||||||
{Org: "a1", Repo: "c", Num: 101},
|
{Org: "a1", Repo: "c", Num: 101},
|
||||||
{Org: "a1", Repo: "c", Num: 100},
|
{Org: "a1", Repo: "c", Num: 100},
|
||||||
{Org: "c", Repo: "b", Num: 100},
|
{Org: "c", Repo: "b", Num: 100},
|
||||||
@ -137,7 +139,7 @@ func TestAppendingPRsToDescription(t *testing.T) {
|
|||||||
|
|
||||||
for _, test := range testTable {
|
for _, test := range testTable {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
d := AppendPRsToDescription(test.desc, test.PRs)
|
d := common.AppendPRsToDescription(test.desc, test.PRs)
|
||||||
if d != test.output {
|
if d != test.output {
|
||||||
t.Error(len(d), "vs", len(test.output))
|
t.Error(len(d), "vs", len(test.output))
|
||||||
t.Error("unpected output", d)
|
t.Error("unpected output", d)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package common
|
package common_test
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of Autogits.
|
* This file is part of Autogits.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package common
|
package common_test
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of Autogits.
|
* This file is part of Autogits.
|
||||||
@ -22,6 +22,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"src.opensuse.org/autogits/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TestWriter struct {
|
type TestWriter struct {
|
||||||
@ -35,7 +37,7 @@ func TestLogging(t *testing.T) {
|
|||||||
strWriter = bytes.NewBuffer(make([]byte, 0, 10000))
|
strWriter = bytes.NewBuffer(make([]byte, 0, 10000))
|
||||||
errWriter = bytes.NewBuffer(make([]byte, 0, 10000))
|
errWriter = bytes.NewBuffer(make([]byte, 0, 10000))
|
||||||
|
|
||||||
stdLogger, errLogger := CreateStdoutLogger(strWriter, errWriter)
|
stdLogger, errLogger := common.CreateStdoutLogger(strWriter, errWriter)
|
||||||
errLogger.Printf("%d\n", 100)
|
errLogger.Printf("%d\n", 100)
|
||||||
stdLogger.Printf("OKA %d Done\n", 77)
|
stdLogger.Printf("OKA %d Done\n", 77)
|
||||||
stdLogger.Println("Another line")
|
stdLogger.Println("Another line")
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package main
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
"src.opensuse.org/autogits/common"
|
|
||||||
"src.opensuse.org/autogits/common/gitea-generated/client/repository"
|
"src.opensuse.org/autogits/common/gitea-generated/client/repository"
|
||||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||||
)
|
)
|
||||||
@ -38,7 +37,7 @@ func parseMaintainershipData(data []byte) (*MaintainershipMap, error) {
|
|||||||
return maintainers, nil
|
return maintainers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func FetchProjectMaintainershipData(gitea common.GiteaMaintainershipReader, org, prjGit, branch string) (*MaintainershipMap, error) {
|
func FetchProjectMaintainershipData(gitea GiteaMaintainershipReader, org, prjGit, branch string) (*MaintainershipMap, error) {
|
||||||
data, err := gitea.FetchMaintainershipDirFile(org, prjGit, branch, ProjectFileKey)
|
data, err := gitea.FetchMaintainershipDirFile(org, prjGit, branch, ProjectFileKey)
|
||||||
dir := true
|
dir := true
|
||||||
if err != nil || data == nil {
|
if err != nil || data == nil {
|
||||||
@ -143,7 +142,7 @@ func (data *MaintainershipMap) IsApproved(pkg string, reviews []*models.PullRevi
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, review := range reviews {
|
for _, review := range reviews {
|
||||||
if !review.Stale && review.State == common.ReviewStateApproved && slices.Contains(reviewers, review.User.UserName) {
|
if !review.Stale && review.State == ReviewStateApproved && slices.Contains(reviewers, review.User.UserName) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package main
|
package common_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@ -122,7 +122,7 @@ func TestMaintainership(t *testing.T) {
|
|||||||
notFoundError := repository.NewRepoGetRawFileNotFound()
|
notFoundError := repository.NewRepoGetRawFileNotFound()
|
||||||
for _, test := range packageTests {
|
for _, test := range packageTests {
|
||||||
runTests := func(t *testing.T, mi common.GiteaMaintainershipReader) {
|
runTests := func(t *testing.T, mi common.GiteaMaintainershipReader) {
|
||||||
maintainers, err := FetchProjectMaintainershipData(mi, config.Organization, config.GitProjectName, config.Branch)
|
maintainers, err := common.FetchProjectMaintainershipData(mi, config.Organization, config.GitProjectName, config.Branch)
|
||||||
if err != nil && !test.otherError {
|
if err != nil && !test.otherError {
|
||||||
if test.maintainersFileErr == nil {
|
if test.maintainersFileErr == nil {
|
||||||
t.Fatal("Unexpected error recieved", err)
|
t.Fatal("Unexpected error recieved", err)
|
||||||
@ -159,7 +159,7 @@ func TestMaintainership(t *testing.T) {
|
|||||||
// tests with maintainership file
|
// tests with maintainership file
|
||||||
mi.EXPECT().FetchMaintainershipFile("foo", common.DefaultGitPrj, "bar").
|
mi.EXPECT().FetchMaintainershipFile("foo", common.DefaultGitPrj, "bar").
|
||||||
Return(test.maintainersFile, test.maintainersFileErr)
|
Return(test.maintainersFile, test.maintainersFileErr)
|
||||||
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", ProjectFileKey).
|
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", common.ProjectFileKey).
|
||||||
Return(nil, notFoundError)
|
Return(nil, notFoundError)
|
||||||
|
|
||||||
runTests(t, mi)
|
runTests(t, mi)
|
||||||
@ -173,8 +173,8 @@ func TestMaintainership(t *testing.T) {
|
|||||||
for filename, data := range test.maintainersDir {
|
for filename, data := range test.maintainersDir {
|
||||||
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", filename).Return(data, test.maintainersFileErr).AnyTimes()
|
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", filename).Return(data, test.maintainersFileErr).AnyTimes()
|
||||||
}
|
}
|
||||||
if _, found := test.maintainersDir[ProjectFileKey]; !found {
|
if _, found := test.maintainersDir[common.ProjectFileKey]; !found {
|
||||||
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", ProjectFileKey).Return(nil, test.maintainersFileErr).AnyTimes()
|
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", common.ProjectFileKey).Return(nil, test.maintainersFileErr).AnyTimes()
|
||||||
mi.EXPECT().FetchMaintainershipFile("foo", common.DefaultGitPrj, "bar").Return(nil, test.maintainersFileErr).AnyTimes()
|
mi.EXPECT().FetchMaintainershipFile("foo", common.DefaultGitPrj, "bar").Return(nil, test.maintainersFileErr).AnyTimes()
|
||||||
}
|
}
|
||||||
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", gomock.Any()).Return(nil, notFoundError).AnyTimes()
|
mi.EXPECT().FetchMaintainershipDirFile("foo", common.DefaultGitPrj, "bar", gomock.Any()).Return(nil, notFoundError).AnyTimes()
|
@ -44,7 +44,7 @@ func (*PushWebhookEvent) GetAction() string {
|
|||||||
return "push"
|
return "push"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *RequestHandler) parsePushRequest(data io.Reader) (*PushWebhookEvent, error) {
|
func (h *RequestHandler) ParsePushRequest(data io.Reader) (*PushWebhookEvent, error) {
|
||||||
action := new(PushWebhookEvent)
|
action := new(PushWebhookEvent)
|
||||||
err := json.NewDecoder(data).Decode(&action)
|
err := json.NewDecoder(data).Decode(&action)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package common
|
package common_test
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of Autogits.
|
* This file is part of Autogits.
|
||||||
@ -22,14 +22,16 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"src.opensuse.org/autogits/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPushRequestParsing(t *testing.T) {
|
func TestPushRequestParsing(t *testing.T) {
|
||||||
t.Run("parsing repo creation message", func(t *testing.T) {
|
t.Run("parsing repo creation message", func(t *testing.T) {
|
||||||
var h RequestHandler
|
var h common.RequestHandler
|
||||||
|
|
||||||
h.StdLogger, h.ErrLogger = CreateStdoutLogger(os.Stdout, os.Stderr)
|
h.StdLogger, h.ErrLogger = common.CreateStdoutLogger(os.Stdout, os.Stderr)
|
||||||
json, err := h.parsePushRequest(strings.NewReader(examplePushJSON))
|
json, err := h.ParsePushRequest(strings.NewReader(examplePushJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to parser push request: %v", err)
|
t.Fatalf("failed to parser push request: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ func (r *RepositoryWebhookEvent) GetAction() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: sanity check values!!!!
|
// TODO: sanity check values!!!!
|
||||||
func (h *RequestHandler) parseRepositoryRequest(dataReader io.Reader) (data *RepositoryWebhookEvent, err error) {
|
func (h *RequestHandler) ParseRepositoryRequest(dataReader io.Reader) (data *RepositoryWebhookEvent, err error) {
|
||||||
data = new(RepositoryWebhookEvent)
|
data = new(RepositoryWebhookEvent)
|
||||||
if err = json.NewDecoder(dataReader).Decode(&data); err != nil {
|
if err = json.NewDecoder(dataReader).Decode(&data); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package common
|
package common_test
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of Autogits.
|
* This file is part of Autogits.
|
||||||
@ -22,6 +22,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"src.opensuse.org/autogits/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testLogger struct {
|
type testLogger struct {
|
||||||
@ -35,10 +37,10 @@ func (s *testLogger) WriteString(str2 string) (int, error) {
|
|||||||
|
|
||||||
func TestRepositoryRequestParsing(t *testing.T) {
|
func TestRepositoryRequestParsing(t *testing.T) {
|
||||||
t.Run("parsing repo creation message", func(t *testing.T) {
|
t.Run("parsing repo creation message", func(t *testing.T) {
|
||||||
var h RequestHandler
|
var h common.RequestHandler
|
||||||
|
|
||||||
h.StdLogger, h.ErrLogger = CreateStdoutLogger(os.Stdout, os.Stdout)
|
h.StdLogger, h.ErrLogger = common.CreateStdoutLogger(os.Stdout, os.Stdout)
|
||||||
json, err := h.parseRepositoryRequest(strings.NewReader(repoCreateJSON))
|
json, err := h.ParseRepositoryRequest(strings.NewReader(repoCreateJSON))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Can't parse struct: %s", err)
|
t.Fatalf("Can't parse struct: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ next_rs:
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *PRSet) AssignReviewers(gitea common.GiteaReviewFetcherAndRequester, maintainers MaintainershipData) error {
|
func (rs *PRSet) AssignReviewers(gitea common.GiteaReviewFetcherAndRequester, maintainers common.MaintainershipData) error {
|
||||||
configReviewers := ParseReviewers(rs.config.Reviewers)
|
configReviewers := ParseReviewers(rs.config.Reviewers)
|
||||||
|
|
||||||
for _, pr := range rs.prs {
|
for _, pr := range rs.prs {
|
||||||
@ -173,7 +173,7 @@ func (rs *PRSet) AssignReviewers(gitea common.GiteaReviewFetcherAndRequester, ma
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *PRSet) IsApproved(gitea common.GiteaPRChecker, maintainers MaintainershipData) bool {
|
func (rs *PRSet) IsApproved(gitea common.GiteaPRChecker, maintainers common.MaintainershipData) bool {
|
||||||
configReviewers := ParseReviewers(rs.config.Reviewers)
|
configReviewers := ParseReviewers(rs.config.Reviewers)
|
||||||
|
|
||||||
is_reviewed := false
|
is_reviewed := false
|
||||||
|
@ -74,7 +74,7 @@ referencing the following pull request:
|
|||||||
|
|
||||||
// request build review
|
// request build review
|
||||||
log.Println("num of current reviewers:", len(PR.RequestedReviewers))
|
log.Println("num of current reviewers:", len(PR.RequestedReviewers))
|
||||||
maintainers, err := FetchProjectMaintainershipData(o.gitea, config.Organization, config.GitProjectName, config.Branch)
|
maintainers, err := common.FetchProjectMaintainershipData(o.gitea, config.Organization, config.GitProjectName, config.Branch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ func (o *PullRequestReviewed) Process(req *common.PullRequestWebhookEvent, git c
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
maintainers, err := FetchProjectMaintainershipData(o.gitea, prset.config.Organization, prset.config.GitProjectName, prset.config.Branch)
|
maintainers, err := common.FetchProjectMaintainershipData(o.gitea, prset.config.Organization, prset.config.GitProjectName, prset.config.Branch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import (
|
|||||||
"src.opensuse.org/autogits/common"
|
"src.opensuse.org/autogits/common"
|
||||||
"src.opensuse.org/autogits/common/gitea-generated/models"
|
"src.opensuse.org/autogits/common/gitea-generated/models"
|
||||||
mock_common "src.opensuse.org/autogits/common/mock"
|
mock_common "src.opensuse.org/autogits/common/mock"
|
||||||
mock_main "src.opensuse.org/workflow-pr/mock"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPR(t *testing.T) {
|
func TestPR(t *testing.T) {
|
||||||
@ -222,7 +221,7 @@ func TestPR(t *testing.T) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
maintainers := mock_main.NewMockMaintainershipData(ctl)
|
maintainers := mock_common.NewMockMaintainershipData(ctl)
|
||||||
maintainers.EXPECT().IsApproved(gomock.Any(), gomock.Any()).Return(true).AnyTimes()
|
maintainers.EXPECT().IsApproved(gomock.Any(), gomock.Any()).Return(true).AnyTimes()
|
||||||
|
|
||||||
if isApproved := res.IsApproved(review_mock, maintainers); isApproved != test.reviewed {
|
if isApproved := res.IsApproved(review_mock, maintainers); isApproved != test.reviewed {
|
||||||
@ -361,7 +360,7 @@ func TestPRAssignReviewers(t *testing.T) {
|
|||||||
ctl := gomock.NewController(t)
|
ctl := gomock.NewController(t)
|
||||||
pr_mock := mock_common.NewMockGiteaPRFetcher(ctl)
|
pr_mock := mock_common.NewMockGiteaPRFetcher(ctl)
|
||||||
review_mock := mock_common.NewMockGiteaReviewFetcherAndRequester(ctl)
|
review_mock := mock_common.NewMockGiteaReviewFetcherAndRequester(ctl)
|
||||||
maintainership_mock := mock_main.NewMockMaintainershipData(ctl)
|
maintainership_mock := mock_common.NewMockMaintainershipData(ctl)
|
||||||
|
|
||||||
pr_mock.EXPECT().GetPullRequest("other", "pkgrepo", int64(1)).Return(&models.PullRequest{
|
pr_mock.EXPECT().GetPullRequest("other", "pkgrepo", int64(1)).Return(&models.PullRequest{
|
||||||
Body: "Some description is here",
|
Body: "Some description is here",
|
||||||
@ -431,7 +430,7 @@ func TestPRAssignReviewers(t *testing.T) {
|
|||||||
ctl := gomock.NewController(t)
|
ctl := gomock.NewController(t)
|
||||||
pr_mock := mock_common.NewMockGiteaPRFetcher(ctl)
|
pr_mock := mock_common.NewMockGiteaPRFetcher(ctl)
|
||||||
review_mock := mock_common.NewMockGiteaReviewFetcherAndRequester(ctl)
|
review_mock := mock_common.NewMockGiteaReviewFetcherAndRequester(ctl)
|
||||||
maintainership_mock := mock_main.NewMockMaintainershipData(ctl)
|
maintainership_mock := mock_common.NewMockMaintainershipData(ctl)
|
||||||
|
|
||||||
pr_mock.EXPECT().GetPullRequest("org", "repo", int64(1)).Return(&models.PullRequest{
|
pr_mock.EXPECT().GetPullRequest("org", "repo", int64(1)).Return(&models.PullRequest{
|
||||||
Body: "Some description is here",
|
Body: "Some description is here",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user