workflow-pr: more unit tests

This commit is contained in:
2024-11-25 17:02:48 +01:00
parent b96c4d26ca
commit e56f444960
3 changed files with 200 additions and 39 deletions

View File

@@ -65,8 +65,6 @@ func updateOrCreatePRBranch(req *common.PullRequestWebhookEvent, git *common.Git
}
var DebugMode bool
var checkOnStart bool
var checkInterval time.Duration
func main() {
if err := common.RequireGiteaSecretToken(); err != nil {
@@ -80,12 +78,10 @@ func main() {
giteaHost := flag.String("gitea", "src.opensuse.org", "Gitea instance")
rabbitUrl := flag.String("url", "amqps://rabbit.opensuse.org", "URL for RabbitMQ instance")
flag.BoolVar(&DebugMode, "debug", false, "Extra debugging information")
flag.BoolVar(&checkOnStart, "check-on-start", false, "Check all repositories for consistency on start, without delays")
checkOnStart := flag.Bool("check-on-start", false, "Check all repositories for consistency on start, without delays")
checkIntervalHours := flag.Float64("check-interval", 5, "Check interval (+-random delay) for repositories for consitency, in hours")
flag.Parse()
checkInterval = time.Duration(*checkIntervalHours) * time.Hour
if len(*workflowConfig) == 0 {
log.Fatalln("No configuratio file specified. Aborting")
}
@@ -115,23 +111,20 @@ func main() {
}
}
gitea := common.AllocateGiteaTransport(*giteaHost)
checker := &DefaultStateChecker {
gitea: common.AllocateGiteaTransport(*giteaHost),
git: &common.GitHandlerImpl{},
}
req.Synced = &PullRequestSynced{
gitea: checker.gitea,
gitea: gitea,
}
req.Opened = &PullRequestOpened{
gitea: checker.gitea,
gitea: gitea,
}
req.Closed = &PullRequestClosed{
gitea: checker.gitea,
gitea: gitea,
}
go checker.consistencyCheckProcess(req)
checker := CreateDefaultStateChecker(*checkOnStart, req, gitea, time.Duration(*checkIntervalHours)*time.Hour)
go checker.ConsistencyCheckProcess()
var defs common.ListenDefinitions