workflow-pr: tests
This commit is contained in:
parent
f281986c8f
commit
2bc9830a7a
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"go.uber.org/mock/gomock"
|
||||
@ -195,9 +196,10 @@ func TestVerifyProjectState(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("Project state with 1 PRs", func(t *testing.T) {
|
||||
t.Run("Project state with 1 PRs that doesn't trigger updates", func(t *testing.T) {
|
||||
ctl := gomock.NewController(t)
|
||||
gitea := mock_common.NewMockGitea(ctl)
|
||||
process := mock_main.NewMockPullRequestProcessor(ctl)
|
||||
|
||||
git := &common.GitHandler{
|
||||
DebugLogger: true,
|
||||
@ -225,15 +227,49 @@ func TestVerifyProjectState(t *testing.T) {
|
||||
gitea.EXPECT().CreateRepositoryIfNotExist(gomock.Any(), gomock.Any(), config1.GitProjectName).Return(&models.Repository{
|
||||
SSHURL: "./prj",
|
||||
}, nil)
|
||||
|
||||
gitea.EXPECT().GetRecentPullRequests(org, "testRepo").Return([]*models.PullRequest{
|
||||
&models.PullRequest{
|
||||
}}, nil)
|
||||
ID: 1234,
|
||||
URL: "url here",
|
||||
Index: 1234,
|
||||
State: "open",
|
||||
Labels: []*models.Label{
|
||||
&models.Label{
|
||||
ID: 1,
|
||||
},
|
||||
},
|
||||
User: &models.User{},
|
||||
|
||||
Base: &models.PRBranchInfo {
|
||||
Name: "one",
|
||||
Ref: "main",
|
||||
Sha: "123",
|
||||
Repo: &models.Repository {
|
||||
Owner: &models.User {
|
||||
},
|
||||
},
|
||||
},
|
||||
Head: &models.PRBranchInfo {
|
||||
Name: "one",
|
||||
Ref: "main",
|
||||
Sha: "123",
|
||||
Repo: &models.Repository {
|
||||
Owner: &models.User {
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, nil)
|
||||
|
||||
gitea.EXPECT().GetRecentCommits(org, "testRepo", "testing", gomock.Any())
|
||||
|
||||
c := CreateDefaultStateChecker(false, configs, gitea, 0)
|
||||
c.git = &testGit{
|
||||
git: git,
|
||||
}
|
||||
process.EXPECT().Process(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
c.processor.Opened = process
|
||||
|
||||
err := c.VerifyProjectState("repo1_org", configs.configuredRepos[org], 0)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user