2024-07-07 21:08:41 +02:00
|
|
|
package main
|
|
|
|
|
2024-10-30 16:55:51 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"src.opensuse.org/autogits/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestProjectBranchName(t *testing.T) {
|
|
|
|
req := common.PullRequestWebhookEvent{
|
|
|
|
Repository: &common.Repository{
|
|
|
|
Name: "testingRepo",
|
|
|
|
},
|
|
|
|
Pull_Request: &common.PullRequest{
|
|
|
|
Number: 10,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
branchName := prGitBranchNameForPR(&req)
|
|
|
|
if branchName != "PR_testingRepo#10" {
|
|
|
|
t.Error("Unexpected branch name:", branchName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestProjctGitSync(t *testing.T) {
|
|
|
|
req := common.PullRequestWebhookEvent{
|
|
|
|
Action: "pull",
|
|
|
|
Number: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := processPrjGitPullRequestSync(&req); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func setupGitForTests(dir string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPkgGitSync(t *testing.T) {
|
|
|
|
req := common.PullRequestWebhookEvent{
|
|
|
|
Repository: &common.Repository{
|
|
|
|
Name: "testRepo",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
git := common.GitHandler{
|
|
|
|
DebugLogger: true,
|
|
|
|
GitCommiter: "TestCommiter",
|
|
|
|
GitEmail: "test@testing",
|
|
|
|
GitPath: t.TempDir(),
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := setupGitForTests(git.GitPath); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := updateOrCreatePRBranch(&req, &git, "created commit", "testing"); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|