2024-07-07 21:08:41 +02:00
|
|
|
package main
|
|
|
|
|
2024-07-31 16:52:02 +02:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"src.opensuse.org/autogits/common/gitea-generated/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPRtoObsProjectMapping(t *testing.T) {
|
|
|
|
pr := models.PullRequest{
|
|
|
|
Base: &models.PRBranchInfo {
|
|
|
|
Repo: &models.Repository {
|
|
|
|
Name: "Repo",
|
|
|
|
Owner: &models.User {
|
|
|
|
UserName: "foobar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Index: 10,
|
|
|
|
}
|
|
|
|
p := getObsProjectAssociatedWithPr("home:foo", &pr)
|
|
|
|
if p != "home:foo:foobar:Repo:PR:10" {
|
|
|
|
t.Errorf("invalid project: %s", p)
|
|
|
|
}
|
|
|
|
|
|
|
|
pr.Base.Repo.Name = "_FooBar"
|
|
|
|
p = getObsProjectAssociatedWithPr("home:foo", &pr)
|
|
|
|
if p != "home:foo:foobar:XFooBar:PR:10" {
|
|
|
|
t.Errorf("invalid project: %s", p)
|
|
|
|
}
|
|
|
|
|
|
|
|
pr.Base.Repo.Owner.UserName = "_some_thing"
|
|
|
|
p = getObsProjectAssociatedWithPr("home:foo", &pr)
|
|
|
|
if p != "home:foo:Xsome_thing:XFooBar:PR:10" {
|
|
|
|
t.Errorf("invalid project: %s", p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|