main.go: log errors if they are returned from runner.Trigger()

This commit is contained in:
Florian Klink 2019-12-03 11:07:44 +01:00
parent 241ec393ac
commit 200ad6332b
2 changed files with 38 additions and 2 deletions

10
main.go
View file

@ -107,13 +107,19 @@ func main() {
handler := frontend.MakeFrontend(rotatingLogHandler, gerrit, runner)
// fetch only on first run
runner.Trigger(fetchOnly)
err = runner.Trigger(fetchOnly)
if err != nil {
log.Error(err.Error())
}
// ticker
go func() {
for {
time.Sleep(time.Duration(triggerInterval) * time.Second)
runner.Trigger(fetchOnly)
err = runner.Trigger(fetchOnly)
if err != nil {
log.Error(err.Error())
}
}
}()

View file

@ -0,0 +1,30 @@
package submitqueue
// import (
// "testing"
// "github.com/apex/log"
// "github.com/apex/log/handlers/memory"
// "github.com/tweag/gerrit-queue/gerrit"
// )
// type MockClient struct {
// gerrit.Client
// }
// func (c *MockClient) Refresh() error {
// return nil
// }
// func TestNewRunner(t *testing.T) {
// logger := &log.Logger{
// Handler: memory.New(),
// }
// //TODO
// gerrit := &MockClient {
// client: nil,
// }
// submitQueueTag := "submitme"
// runner := NewRunner(logger, gerrit, submitQueueTag)
// }