Files
atlantis/server/scheduled/executor_service_test.go
Ken Kaizu 3954955e13 fix(deps): update module github.com/petergtz/pegomock/v3 to v4 (#3534)
* fix(deps): update module github.com/petergtz/pegomock/v3 to v4 in go.mod

* remove pegomock generate m option, which is not support after v4

* make regen-mocks

* replace pegomock v4 primitive eq/matchers

* convert pegomock v4 Eq/Any matchers

* remove custom models.Repo matcher

* pegomock v4 cannot use result method args

ref https://github.com/petergtz/pegomock/issues/123

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-06-20 15:05:23 -04:00

49 lines
930 B
Go

package scheduled
import (
"testing"
"time"
pegomock "github.com/petergtz/pegomock/v4"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/scheduled/mocks"
)
func TestExecutorService_Run(t *testing.T) {
pegomock.RegisterMockTestingT(t)
mockJob := mocks.NewMockJob()
type fields struct {
log logging.SimpleLogging
jobs []JobDefinition
}
tests := []struct {
name string
fields fields
}{
{
name: "test",
fields: fields{
log: logging.NewNoopLogger(t),
jobs: []JobDefinition{
{
Job: mockJob,
Period: 1 * time.Second,
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s := &ExecutorService{
log: tt.fields.log,
jobs: make([]JobDefinition, 0),
}
s.AddJob(tt.fields.jobs[0])
go s.Run()
time.Sleep(1050 * time.Millisecond)
mockJob.VerifyWasCalledOnce().Run()
})
}
}