wip tests
This commit is contained in:
parent
48a889b353
commit
0f6cb392d6
@ -1,4 +1,6 @@
|
||||
package main
|
||||
|
||||
// TODO, like documentation :-)
|
||||
|
||||
func test()
|
||||
{
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user