wip tests

This commit is contained in:
Adam Majer 2024-10-30 16:55:51 +01:00
parent 48a889b353
commit 0f6cb392d6
2 changed files with 62 additions and 2 deletions

View File

@ -1,4 +1,6 @@
package main
// TODO, like documentation :-)
func test()
{
}

View File

@ -1,3 +1,61 @@
package main
// TODO
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)
}
}