diff --git a/.github/workflows/arc-publish.yaml b/.github/workflows/arc-publish.yaml index 8d635bb2..b90a55b4 100644 --- a/.github/workflows/arc-publish.yaml +++ b/.github/workflows/arc-publish.yaml @@ -47,9 +47,7 @@ jobs: - name: Install tools run: | - curl -L -O https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.2.0/kubebuilder_2.2.0_linux_amd64.tar.gz - tar zxvf kubebuilder_2.2.0_linux_amd64.tar.gz - sudo mv kubebuilder_2.2.0_linux_amd64 /usr/local/kubebuilder + curl -s https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash sudo mv kustomize /usr/local/bin curl -L -O https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index b36b8aa4..d8182a0e 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -76,13 +76,11 @@ jobs: - run: make manifests - name: Check diff run: git diff --exit-code - - name: Install kubebuilder + - name: Setup envtest run: | - curl -D headers.txt -fsL "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-1.30.0-linux-amd64.tar.gz" -o kubebuilder-tools - echo "$(grep -i etag headers.txt -m 1 | cut -d'"' -f2) kubebuilder-tools" > sum - md5sum -c sum - tar -zvxf kubebuilder-tools - sudo mv kubebuilder /usr/local/ + go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(go list -m -f '{{ .Version }}' sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $2, $3}') + ENVTEST_K8S_VERSION=$(go list -m -f '{{ .Version }}' k8s.io/api | awk -F'[v.]' '{printf "1.%d", $3}') + echo "KUBEBUILDER_ASSETS=$(setup-envtest use ${ENVTEST_K8S_VERSION} -p path)" >> $GITHUB_ENV - name: Run go tests run: | go test -short `go list ./... | grep -v ./test_e2e_arc` diff --git a/.gitignore b/.gitignore index e0fcafbf..713cf538 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,5 @@ bin # OS .DS_STORE -/test-assets + /.tools diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 00000000..6b663c20 --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,29 @@ +all: false +packages: + github.com/actions/actions-runner-controller/github/actions: + config: + inpackage: true + interfaces: + ActionsService: + SessionService: + + github.com/actions/actions-runner-controller/cmd/ghalistener/metrics: + config: + dir: "{{.InterfaceDir}}/mocks" + pkgname: mocks + filename: "{{.InterfaceName|snakecase}}.go" + interfaces: + Publisher: + ServerExporter: + config: + structname: ServerPublisher + filename: server_publisher.go + + github.com/actions/actions-runner-controller/cmd/ghalistener/app: + config: + dir: "{{.InterfaceDir}}/mocks" + pkgname: mocks + filename: "{{.InterfaceName|snakecase}}.go" + interfaces: + Listener: + Worker: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b62b5bb..58dd75df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,22 +102,19 @@ A set of example pipelines (./acceptance/pipelines) are provided in this reposit When raising a PR please run the relevant suites to prove your change hasn't broken anything. #### Running Ginkgo Tests - You can run the integration test suite that is written in Ginkgo with: ```shell make test-with-deps ``` -This will firstly install a few binaries required to setup the integration test environment and then runs `go test` to start the Ginkgo test. +This will install `setup-envtest`, download the required envtest binaries (etcd, kube-apiserver, kubectl), and then run `go test`. -If you don't want to use `make`, like when you're running tests from your IDE, install required binaries to `/usr/local/kubebuilder/bin`. -That's the directory in which controller-runtime's `envtest` framework locates the binaries. +If you don't want to use `make`, install the envtest binaries using `setup-envtest`: ```shell -sudo mkdir -p /usr/local/kubebuilder/bin -make kube-apiserver etcd -sudo mv test-assets/{etcd,kube-apiserver} /usr/local/kubebuilder/bin/ +go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest +export KUBEBUILDER_ASSETS=$(setup-envtest use -p path) go test -v -run TestAPIs github.com/actions/actions-runner-controller/controllers/actions.summerwind.net ``` diff --git a/Makefile b/Makefile index 06f98f65..1a47572c 100644 --- a/Makefile +++ b/Makefile @@ -32,21 +32,15 @@ else GOBIN=$(shell go env GOBIN) endif -TEST_ASSETS=$(PWD)/test-assets TOOLS_PATH=$(PWD)/.tools OS_NAME := $(shell uname -s | tr A-Z a-z) -# The etcd packages that coreos maintain use different extensions for each *nix OS on their github release page. -# ETCD_EXTENSION: the storage format file extension listed on the release page. -# EXTRACT_COMMAND: the appropriate CLI command for extracting this file format. -ifeq ($(OS_NAME), darwin) -ETCD_EXTENSION:=zip -EXTRACT_COMMAND:=unzip -else -ETCD_EXTENSION:=tar.gz -EXTRACT_COMMAND:=tar -xzf -endif +# ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script +ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}') +# ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries +ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}') +ENVTEST ?= $(GOBIN)/setup-envtest # default list of platforms for which multiarch image is built ifeq (${PLATFORMS}, ) @@ -72,18 +66,19 @@ lint: GO_TEST_ARGS ?= -short -# Run tests -test: generate fmt vet manifests shellcheck - go test $(GO_TEST_ARGS) `go list ./... | grep -v ./test_e2e_arc` -coverprofile cover.out - go test -fuzz=Fuzz -fuzztime=10s -run=Fuzz* ./controllers/actions.summerwind.net -test-with-deps: kube-apiserver etcd kubectl - # See https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest#pkg-constants - TEST_ASSET_KUBE_APISERVER=$(KUBE_APISERVER_BIN) \ - TEST_ASSET_ETCD=$(ETCD_BIN) \ - TEST_ASSET_KUBECTL=$(KUBECTL_BIN) \ +# Run tests +test: generate fmt vet manifests shellcheck setup-envtest + KUBEBUILDER_ASSETS="$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(GOBIN) -p path)" \ + go test $(GO_TEST_ARGS) `go list ./... | grep -v ./test_e2e_arc` -coverprofile cover.out + KUBEBUILDER_ASSETS="$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(GOBIN) -p path)" \ + go test -fuzz=Fuzz -fuzztime=10s -run=Fuzz* ./controllers/actions.summerwind.net + +test-with-deps: setup-envtest + KUBEBUILDER_ASSETS="$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(GOBIN) -p path)" \ make test + # Build manager binary manager: generate fmt vet go build -o bin/manager main.go @@ -364,68 +359,29 @@ ifeq (, $(wildcard $(TOOLS_PATH)/shellcheck)) endif SHELLCHECK=$(TOOLS_PATH)/shellcheck -# find or download etcd -etcd: -ifeq (, $(shell which etcd)) -ifeq (, $(wildcard $(TEST_ASSETS)/etcd)) +# find or download envtest +envtest: +ifeq (, $(shell which setup-envtest)) +ifeq (, $(wildcard $(GOBIN)/setup-envtest)) @{ \ - set -xe ;\ - INSTALL_TMP_DIR=$$(mktemp -d) ;\ - cd $$INSTALL_TMP_DIR ;\ - wget https://github.com/coreos/etcd/releases/download/v3.4.22/etcd-v3.4.22-$(OS_NAME)-amd64.$(ETCD_EXTENSION);\ - mkdir -p $(TEST_ASSETS) ;\ - $(EXTRACT_COMMAND) etcd-v3.4.22-$(OS_NAME)-amd64.$(ETCD_EXTENSION) ;\ - mv etcd-v3.4.22-$(OS_NAME)-amd64/etcd $(TEST_ASSETS)/etcd ;\ - rm -rf $$INSTALL_TMP_DIR ;\ + set -e ;\ + ENVTEST_TMP_DIR=$$(mktemp -d) ;\ + cd $$ENVTEST_TMP_DIR ;\ + go mod init tmp ;\ + go install sigs.k8s.io/controller-runtime/tools/setup-envtest@$(ENVTEST_VERSION) ;\ + rm -rf $$ENVTEST_TMP_DIR ;\ } -ETCD_BIN=$(TEST_ASSETS)/etcd -else -ETCD_BIN=$(TEST_ASSETS)/etcd endif +ENVTEST=$(GOBIN)/setup-envtest else -ETCD_BIN=$(shell which etcd) +ENVTEST=$(shell which setup-envtest) endif -# find or download kube-apiserver -kube-apiserver: -ifeq (, $(shell which kube-apiserver)) -ifeq (, $(wildcard $(TEST_ASSETS)/kube-apiserver)) - @{ \ - set -xe ;\ - INSTALL_TMP_DIR=$$(mktemp -d) ;\ - cd $$INSTALL_TMP_DIR ;\ - wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_$(OS_NAME)_amd64.tar.gz ;\ - mkdir -p $(TEST_ASSETS) ;\ - tar zxvf kubebuilder_2.3.2_$(OS_NAME)_amd64.tar.gz ;\ - mv kubebuilder_2.3.2_$(OS_NAME)_amd64/bin/kube-apiserver $(TEST_ASSETS)/kube-apiserver ;\ - rm -rf $$INSTALL_TMP_DIR ;\ +.PHONY: setup-envtest +setup-envtest: envtest + @echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..." + @$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(GOBIN) -p path || { \ + echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \ + exit 1; \ } -KUBE_APISERVER_BIN=$(TEST_ASSETS)/kube-apiserver -else -KUBE_APISERVER_BIN=$(TEST_ASSETS)/kube-apiserver -endif -else -KUBE_APISERVER_BIN=$(shell which kube-apiserver) -endif -# find or download kubectl -kubectl: -ifeq (, $(shell which kubectl)) -ifeq (, $(wildcard $(TEST_ASSETS)/kubectl)) - @{ \ - set -xe ;\ - INSTALL_TMP_DIR=$$(mktemp -d) ;\ - cd $$INSTALL_TMP_DIR ;\ - wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.2/kubebuilder_2.3.2_$(OS_NAME)_amd64.tar.gz ;\ - mkdir -p $(TEST_ASSETS) ;\ - tar zxvf kubebuilder_2.3.2_$(OS_NAME)_amd64.tar.gz ;\ - mv kubebuilder_2.3.2_$(OS_NAME)_amd64/bin/kubectl $(TEST_ASSETS)/kubectl ;\ - rm -rf $$INSTALL_TMP_DIR ;\ - } -KUBECTL_BIN=$(TEST_ASSETS)/kubectl -else -KUBECTL_BIN=$(TEST_ASSETS)/kubectl -endif -else -KUBECTL_BIN=$(shell which kubectl) -endif diff --git a/cmd/ghalistener/app/app.go b/cmd/ghalistener/app/app.go index 004898a7..98604eb2 100644 --- a/cmd/ghalistener/app/app.go +++ b/cmd/ghalistener/app/app.go @@ -26,12 +26,12 @@ type App struct { metrics metrics.ServerExporter } -//go:generate mockery --name Listener --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type Listener interface { Listen(ctx context.Context, handler listener.Handler) error } -//go:generate mockery --name Worker --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type Worker interface { HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error HandleDesiredRunnerCount(ctx context.Context, count int, jobsCompleted int) (int, error) diff --git a/cmd/ghalistener/app/app_test.go b/cmd/ghalistener/app/app_test.go index 883add35..4b6a3700 100644 --- a/cmd/ghalistener/app/app_test.go +++ b/cmd/ghalistener/app/app_test.go @@ -29,8 +29,8 @@ func TestApp_Run(t *testing.T) { }) t.Run("ExitsOnListenerError", func(t *testing.T) { - listener := appmocks.NewListener(t) - worker := appmocks.NewWorker(t) + listener := appmocks.NewMockListener(t) + worker := appmocks.NewMockWorker(t) listener.On("Listen", mock.Anything, mock.Anything).Return(errors.New("listener error")).Once() @@ -44,8 +44,8 @@ func TestApp_Run(t *testing.T) { }) t.Run("ExitsOnListenerNil", func(t *testing.T) { - listener := appmocks.NewListener(t) - worker := appmocks.NewWorker(t) + listener := appmocks.NewMockListener(t) + worker := appmocks.NewMockWorker(t) listener.On("Listen", mock.Anything, mock.Anything).Return(nil).Once() @@ -59,8 +59,8 @@ func TestApp_Run(t *testing.T) { }) t.Run("CancelListenerOnMetricsServerError", func(t *testing.T) { - listener := appmocks.NewListener(t) - worker := appmocks.NewWorker(t) + listener := appmocks.NewMockListener(t) + worker := appmocks.NewMockWorker(t) metrics := metricsMocks.NewServerPublisher(t) ctx := context.Background() diff --git a/cmd/ghalistener/app/mocks/listener.go b/cmd/ghalistener/app/mocks/listener.go index c177ace6..713af413 100644 --- a/cmd/ghalistener/app/mocks/listener.go +++ b/cmd/ghalistener/app/mocks/listener.go @@ -1,43 +1,96 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify package mocks import ( - context "context" + "context" - listener "github.com/actions/actions-runner-controller/cmd/ghalistener/listener" + "github.com/actions/actions-runner-controller/cmd/ghalistener/listener" mock "github.com/stretchr/testify/mock" ) -// Listener is an autogenerated mock type for the Listener type -type Listener struct { - mock.Mock -} - -// Listen provides a mock function with given fields: ctx, handler -func (_m *Listener) Listen(ctx context.Context, handler listener.Handler) error { - ret := _m.Called(ctx, handler) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, listener.Handler) error); ok { - r0 = rf(ctx, handler) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// NewListener creates a new instance of Listener. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockListener creates a new instance of MockListener. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewListener(t interface { +func NewMockListener(t interface { mock.TestingT Cleanup(func()) -}) *Listener { - mock := &Listener{} +}) *MockListener { + mock := &MockListener{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) return mock } + +// MockListener is an autogenerated mock type for the Listener type +type MockListener struct { + mock.Mock +} + +type MockListener_Expecter struct { + mock *mock.Mock +} + +func (_m *MockListener) EXPECT() *MockListener_Expecter { + return &MockListener_Expecter{mock: &_m.Mock} +} + +// Listen provides a mock function for the type MockListener +func (_mock *MockListener) Listen(ctx context.Context, handler listener.Handler) error { + ret := _mock.Called(ctx, handler) + + if len(ret) == 0 { + panic("no return value specified for Listen") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, listener.Handler) error); ok { + r0 = returnFunc(ctx, handler) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockListener_Listen_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Listen' +type MockListener_Listen_Call struct { + *mock.Call +} + +// Listen is a helper method to define mock.On call +// - ctx context.Context +// - handler listener.Handler +func (_e *MockListener_Expecter) Listen(ctx interface{}, handler interface{}) *MockListener_Listen_Call { + return &MockListener_Listen_Call{Call: _e.mock.On("Listen", ctx, handler)} +} + +func (_c *MockListener_Listen_Call) Run(run func(ctx context.Context, handler listener.Handler)) *MockListener_Listen_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 listener.Handler + if args[1] != nil { + arg1 = args[1].(listener.Handler) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockListener_Listen_Call) Return(err error) *MockListener_Listen_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockListener_Listen_Call) RunAndReturn(run func(ctx context.Context, handler listener.Handler) error) *MockListener_Listen_Call { + _c.Call.Return(run) + return _c +} diff --git a/cmd/ghalistener/app/mocks/worker.go b/cmd/ghalistener/app/mocks/worker.go index 9f24819d..67c16130 100644 --- a/cmd/ghalistener/app/mocks/worker.go +++ b/cmd/ghalistener/app/mocks/worker.go @@ -1,68 +1,168 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify package mocks import ( - actions "github.com/actions/actions-runner-controller/github/actions" - - context "context" + "context" + "github.com/actions/actions-runner-controller/github/actions" mock "github.com/stretchr/testify/mock" ) -// Worker is an autogenerated mock type for the Worker type -type Worker struct { - mock.Mock -} - -// HandleDesiredRunnerCount provides a mock function with given fields: ctx, count, acquireCount -func (_m *Worker) HandleDesiredRunnerCount(ctx context.Context, count int, acquireCount int) (int, error) { - ret := _m.Called(ctx, count, acquireCount) - - var r0 int - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, int) (int, error)); ok { - return rf(ctx, count, acquireCount) - } - if rf, ok := ret.Get(0).(func(context.Context, int, int) int); ok { - r0 = rf(ctx, count, acquireCount) - } else { - r0 = ret.Get(0).(int) - } - - if rf, ok := ret.Get(1).(func(context.Context, int, int) error); ok { - r1 = rf(ctx, count, acquireCount) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// HandleJobStarted provides a mock function with given fields: ctx, jobInfo -func (_m *Worker) HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error { - ret := _m.Called(ctx, jobInfo) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *actions.JobStarted) error); ok { - r0 = rf(ctx, jobInfo) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// NewWorker creates a new instance of Worker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockWorker creates a new instance of MockWorker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewWorker(t interface { +func NewMockWorker(t interface { mock.TestingT Cleanup(func()) -}) *Worker { - mock := &Worker{} +}) *MockWorker { + mock := &MockWorker{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) return mock } + +// MockWorker is an autogenerated mock type for the Worker type +type MockWorker struct { + mock.Mock +} + +type MockWorker_Expecter struct { + mock *mock.Mock +} + +func (_m *MockWorker) EXPECT() *MockWorker_Expecter { + return &MockWorker_Expecter{mock: &_m.Mock} +} + +// HandleDesiredRunnerCount provides a mock function for the type MockWorker +func (_mock *MockWorker) HandleDesiredRunnerCount(ctx context.Context, count int, jobsCompleted int) (int, error) { + ret := _mock.Called(ctx, count, jobsCompleted) + + if len(ret) == 0 { + panic("no return value specified for HandleDesiredRunnerCount") + } + + var r0 int + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, int) (int, error)); ok { + return returnFunc(ctx, count, jobsCompleted) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, int) int); ok { + r0 = returnFunc(ctx, count, jobsCompleted) + } else { + r0 = ret.Get(0).(int) + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, int) error); ok { + r1 = returnFunc(ctx, count, jobsCompleted) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockWorker_HandleDesiredRunnerCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleDesiredRunnerCount' +type MockWorker_HandleDesiredRunnerCount_Call struct { + *mock.Call +} + +// HandleDesiredRunnerCount is a helper method to define mock.On call +// - ctx context.Context +// - count int +// - jobsCompleted int +func (_e *MockWorker_Expecter) HandleDesiredRunnerCount(ctx interface{}, count interface{}, jobsCompleted interface{}) *MockWorker_HandleDesiredRunnerCount_Call { + return &MockWorker_HandleDesiredRunnerCount_Call{Call: _e.mock.On("HandleDesiredRunnerCount", ctx, count, jobsCompleted)} +} + +func (_c *MockWorker_HandleDesiredRunnerCount_Call) Run(run func(ctx context.Context, count int, jobsCompleted int)) *MockWorker_HandleDesiredRunnerCount_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 int + if args[2] != nil { + arg2 = args[2].(int) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockWorker_HandleDesiredRunnerCount_Call) Return(n int, err error) *MockWorker_HandleDesiredRunnerCount_Call { + _c.Call.Return(n, err) + return _c +} + +func (_c *MockWorker_HandleDesiredRunnerCount_Call) RunAndReturn(run func(ctx context.Context, count int, jobsCompleted int) (int, error)) *MockWorker_HandleDesiredRunnerCount_Call { + _c.Call.Return(run) + return _c +} + +// HandleJobStarted provides a mock function for the type MockWorker +func (_mock *MockWorker) HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error { + ret := _mock.Called(ctx, jobInfo) + + if len(ret) == 0 { + panic("no return value specified for HandleJobStarted") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *actions.JobStarted) error); ok { + r0 = returnFunc(ctx, jobInfo) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockWorker_HandleJobStarted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleJobStarted' +type MockWorker_HandleJobStarted_Call struct { + *mock.Call +} + +// HandleJobStarted is a helper method to define mock.On call +// - ctx context.Context +// - jobInfo *actions.JobStarted +func (_e *MockWorker_Expecter) HandleJobStarted(ctx interface{}, jobInfo interface{}) *MockWorker_HandleJobStarted_Call { + return &MockWorker_HandleJobStarted_Call{Call: _e.mock.On("HandleJobStarted", ctx, jobInfo)} +} + +func (_c *MockWorker_HandleJobStarted_Call) Run(run func(ctx context.Context, jobInfo *actions.JobStarted)) *MockWorker_HandleJobStarted_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *actions.JobStarted + if args[1] != nil { + arg1 = args[1].(*actions.JobStarted) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockWorker_HandleJobStarted_Call) Return(err error) *MockWorker_HandleJobStarted_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockWorker_HandleJobStarted_Call) RunAndReturn(run func(ctx context.Context, jobInfo *actions.JobStarted) error) *MockWorker_HandleJobStarted_Call { + _c.Call.Return(run) + return _c +} diff --git a/cmd/ghalistener/listener/listener.go b/cmd/ghalistener/listener/listener.go index eb43c401..876fccd7 100644 --- a/cmd/ghalistener/listener/listener.go +++ b/cmd/ghalistener/listener/listener.go @@ -27,7 +27,7 @@ const ( messageTypeJobCompleted = "JobCompleted" ) -//go:generate mockery --name Client --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type Client interface { GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*actions.AcquirableJobList, error) CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*actions.RunnerScaleSetSession, error) @@ -113,7 +113,7 @@ func New(config Config) (*Listener, error) { return listener, nil } -//go:generate mockery --name Handler --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type Handler interface { HandleJobStarted(ctx context.Context, jobInfo *actions.JobStarted) error HandleDesiredRunnerCount(ctx context.Context, count, jobsCompleted int) (int, error) diff --git a/cmd/ghalistener/listener/metrics_test.go b/cmd/ghalistener/listener/metrics_test.go index 975619b9..95cb8019 100644 --- a/cmd/ghalistener/listener/metrics_test.go +++ b/cmd/ghalistener/listener/metrics_test.go @@ -20,7 +20,7 @@ func TestInitialMetrics(t *testing.T) { t.Run("SetStaticMetrics", func(t *testing.T) { t.Parallel() - metrics := metricsmocks.NewPublisher(t) + metrics := metricsmocks.NewMockPublisher(t) minRunners := 5 maxRunners := 10 @@ -64,7 +64,7 @@ func TestInitialMetrics(t *testing.T) { Statistics: sessionStatistics, } - metrics := metricsmocks.NewPublisher(t) + metrics := metricsmocks.NewMockPublisher(t) metrics.On("PublishStatic", mock.Anything, mock.Anything).Once() metrics.On("PublishStatistics", sessionStatistics).Once() metrics.On("PublishDesiredRunners", sessionStatistics.TotalAssignedJobs). @@ -168,7 +168,7 @@ func TestHandleMessageMetrics(t *testing.T) { desiredResult := 4 - metrics := metricsmocks.NewPublisher(t) + metrics := metricsmocks.NewMockPublisher(t) metrics.On("PublishStatic", 0, 0).Once() metrics.On("PublishStatistics", msg.Statistics).Once() metrics.On("PublishJobCompleted", jobsCompleted[0]).Once() diff --git a/cmd/ghalistener/metrics/metrics.go b/cmd/ghalistener/metrics/metrics.go index a9353ccc..6ecacd52 100644 --- a/cmd/ghalistener/metrics/metrics.go +++ b/cmd/ghalistener/metrics/metrics.go @@ -100,7 +100,7 @@ func (e *exporter) startedJobLabels(msg *actions.JobStarted) prometheus.Labels { return e.jobLabels(&msg.JobMessageBase) } -//go:generate mockery --name Publisher --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type Publisher interface { PublishStatic(min, max int) PublishStatistics(stats *actions.RunnerScaleSetStatistic) @@ -109,7 +109,7 @@ type Publisher interface { PublishDesiredRunners(count int) } -//go:generate mockery --name ServerPublisher --output ./mocks --outpkg mocks --case underscore +//go:generate mockery type ServerExporter interface { Publisher ListenAndServe(ctx context.Context) error diff --git a/cmd/ghalistener/metrics/mocks/publisher.go b/cmd/ghalistener/metrics/mocks/publisher.go index 08858594..7d10c542 100644 --- a/cmd/ghalistener/metrics/mocks/publisher.go +++ b/cmd/ghalistener/metrics/mocks/publisher.go @@ -1,53 +1,243 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify package mocks import ( - actions "github.com/actions/actions-runner-controller/github/actions" - + "github.com/actions/actions-runner-controller/github/actions" mock "github.com/stretchr/testify/mock" ) -// Publisher is an autogenerated mock type for the Publisher type -type Publisher struct { - mock.Mock -} - -// PublishDesiredRunners provides a mock function with given fields: count -func (_m *Publisher) PublishDesiredRunners(count int) { - _m.Called(count) -} - -// PublishJobCompleted provides a mock function with given fields: msg -func (_m *Publisher) PublishJobCompleted(msg *actions.JobCompleted) { - _m.Called(msg) -} - -// PublishJobStarted provides a mock function with given fields: msg -func (_m *Publisher) PublishJobStarted(msg *actions.JobStarted) { - _m.Called(msg) -} - -// PublishStatic provides a mock function with given fields: min, max -func (_m *Publisher) PublishStatic(min int, max int) { - _m.Called(min, max) -} - -// PublishStatistics provides a mock function with given fields: stats -func (_m *Publisher) PublishStatistics(stats *actions.RunnerScaleSetStatistic) { - _m.Called(stats) -} - -// NewPublisher creates a new instance of Publisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// NewMockPublisher creates a new instance of MockPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. -func NewPublisher(t interface { +func NewMockPublisher(t interface { mock.TestingT Cleanup(func()) -}) *Publisher { - mock := &Publisher{} +}) *MockPublisher { + mock := &MockPublisher{} mock.Mock.Test(t) t.Cleanup(func() { mock.AssertExpectations(t) }) return mock } + +// MockPublisher is an autogenerated mock type for the Publisher type +type MockPublisher struct { + mock.Mock +} + +type MockPublisher_Expecter struct { + mock *mock.Mock +} + +func (_m *MockPublisher) EXPECT() *MockPublisher_Expecter { + return &MockPublisher_Expecter{mock: &_m.Mock} +} + +// PublishDesiredRunners provides a mock function for the type MockPublisher +func (_mock *MockPublisher) PublishDesiredRunners(count int) { + _mock.Called(count) + return +} + +// MockPublisher_PublishDesiredRunners_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishDesiredRunners' +type MockPublisher_PublishDesiredRunners_Call struct { + *mock.Call +} + +// PublishDesiredRunners is a helper method to define mock.On call +// - count int +func (_e *MockPublisher_Expecter) PublishDesiredRunners(count interface{}) *MockPublisher_PublishDesiredRunners_Call { + return &MockPublisher_PublishDesiredRunners_Call{Call: _e.mock.On("PublishDesiredRunners", count)} +} + +func (_c *MockPublisher_PublishDesiredRunners_Call) Run(run func(count int)) *MockPublisher_PublishDesiredRunners_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockPublisher_PublishDesiredRunners_Call) Return() *MockPublisher_PublishDesiredRunners_Call { + _c.Call.Return() + return _c +} + +func (_c *MockPublisher_PublishDesiredRunners_Call) RunAndReturn(run func(count int)) *MockPublisher_PublishDesiredRunners_Call { + _c.Run(run) + return _c +} + +// PublishJobCompleted provides a mock function for the type MockPublisher +func (_mock *MockPublisher) PublishJobCompleted(msg *actions.JobCompleted) { + _mock.Called(msg) + return +} + +// MockPublisher_PublishJobCompleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJobCompleted' +type MockPublisher_PublishJobCompleted_Call struct { + *mock.Call +} + +// PublishJobCompleted is a helper method to define mock.On call +// - msg *actions.JobCompleted +func (_e *MockPublisher_Expecter) PublishJobCompleted(msg interface{}) *MockPublisher_PublishJobCompleted_Call { + return &MockPublisher_PublishJobCompleted_Call{Call: _e.mock.On("PublishJobCompleted", msg)} +} + +func (_c *MockPublisher_PublishJobCompleted_Call) Run(run func(msg *actions.JobCompleted)) *MockPublisher_PublishJobCompleted_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.JobCompleted + if args[0] != nil { + arg0 = args[0].(*actions.JobCompleted) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockPublisher_PublishJobCompleted_Call) Return() *MockPublisher_PublishJobCompleted_Call { + _c.Call.Return() + return _c +} + +func (_c *MockPublisher_PublishJobCompleted_Call) RunAndReturn(run func(msg *actions.JobCompleted)) *MockPublisher_PublishJobCompleted_Call { + _c.Run(run) + return _c +} + +// PublishJobStarted provides a mock function for the type MockPublisher +func (_mock *MockPublisher) PublishJobStarted(msg *actions.JobStarted) { + _mock.Called(msg) + return +} + +// MockPublisher_PublishJobStarted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJobStarted' +type MockPublisher_PublishJobStarted_Call struct { + *mock.Call +} + +// PublishJobStarted is a helper method to define mock.On call +// - msg *actions.JobStarted +func (_e *MockPublisher_Expecter) PublishJobStarted(msg interface{}) *MockPublisher_PublishJobStarted_Call { + return &MockPublisher_PublishJobStarted_Call{Call: _e.mock.On("PublishJobStarted", msg)} +} + +func (_c *MockPublisher_PublishJobStarted_Call) Run(run func(msg *actions.JobStarted)) *MockPublisher_PublishJobStarted_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.JobStarted + if args[0] != nil { + arg0 = args[0].(*actions.JobStarted) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockPublisher_PublishJobStarted_Call) Return() *MockPublisher_PublishJobStarted_Call { + _c.Call.Return() + return _c +} + +func (_c *MockPublisher_PublishJobStarted_Call) RunAndReturn(run func(msg *actions.JobStarted)) *MockPublisher_PublishJobStarted_Call { + _c.Run(run) + return _c +} + +// PublishStatic provides a mock function for the type MockPublisher +func (_mock *MockPublisher) PublishStatic(min int, max int) { + _mock.Called(min, max) + return +} + +// MockPublisher_PublishStatic_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishStatic' +type MockPublisher_PublishStatic_Call struct { + *mock.Call +} + +// PublishStatic is a helper method to define mock.On call +// - min int +// - max int +func (_e *MockPublisher_Expecter) PublishStatic(min interface{}, max interface{}) *MockPublisher_PublishStatic_Call { + return &MockPublisher_PublishStatic_Call{Call: _e.mock.On("PublishStatic", min, max)} +} + +func (_c *MockPublisher_PublishStatic_Call) Run(run func(min int, max int)) *MockPublisher_PublishStatic_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockPublisher_PublishStatic_Call) Return() *MockPublisher_PublishStatic_Call { + _c.Call.Return() + return _c +} + +func (_c *MockPublisher_PublishStatic_Call) RunAndReturn(run func(min int, max int)) *MockPublisher_PublishStatic_Call { + _c.Run(run) + return _c +} + +// PublishStatistics provides a mock function for the type MockPublisher +func (_mock *MockPublisher) PublishStatistics(stats *actions.RunnerScaleSetStatistic) { + _mock.Called(stats) + return +} + +// MockPublisher_PublishStatistics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishStatistics' +type MockPublisher_PublishStatistics_Call struct { + *mock.Call +} + +// PublishStatistics is a helper method to define mock.On call +// - stats *actions.RunnerScaleSetStatistic +func (_e *MockPublisher_Expecter) PublishStatistics(stats interface{}) *MockPublisher_PublishStatistics_Call { + return &MockPublisher_PublishStatistics_Call{Call: _e.mock.On("PublishStatistics", stats)} +} + +func (_c *MockPublisher_PublishStatistics_Call) Run(run func(stats *actions.RunnerScaleSetStatistic)) *MockPublisher_PublishStatistics_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.RunnerScaleSetStatistic + if args[0] != nil { + arg0 = args[0].(*actions.RunnerScaleSetStatistic) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockPublisher_PublishStatistics_Call) Return() *MockPublisher_PublishStatistics_Call { + _c.Call.Return() + return _c +} + +func (_c *MockPublisher_PublishStatistics_Call) RunAndReturn(run func(stats *actions.RunnerScaleSetStatistic)) *MockPublisher_PublishStatistics_Call { + _c.Run(run) + return _c +} diff --git a/cmd/ghalistener/metrics/mocks/server_publisher.go b/cmd/ghalistener/metrics/mocks/server_publisher.go index 01aac02e..bec4d4ba 100644 --- a/cmd/ghalistener/metrics/mocks/server_publisher.go +++ b/cmd/ghalistener/metrics/mocks/server_publisher.go @@ -1,59 +1,16 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify package mocks import ( - context "context" - - actions "github.com/actions/actions-runner-controller/github/actions" + "context" + "github.com/actions/actions-runner-controller/github/actions" mock "github.com/stretchr/testify/mock" ) -// ServerPublisher is an autogenerated mock type for the ServerPublisher type -type ServerPublisher struct { - mock.Mock -} - -// ListenAndServe provides a mock function with given fields: ctx -func (_m *ServerPublisher) ListenAndServe(ctx context.Context) error { - ret := _m.Called(ctx) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context) error); ok { - r0 = rf(ctx) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// PublishDesiredRunners provides a mock function with given fields: count -func (_m *ServerPublisher) PublishDesiredRunners(count int) { - _m.Called(count) -} - -// PublishJobCompleted provides a mock function with given fields: msg -func (_m *ServerPublisher) PublishJobCompleted(msg *actions.JobCompleted) { - _m.Called(msg) -} - -// PublishJobStarted provides a mock function with given fields: msg -func (_m *ServerPublisher) PublishJobStarted(msg *actions.JobStarted) { - _m.Called(msg) -} - -// PublishStatic provides a mock function with given fields: min, max -func (_m *ServerPublisher) PublishStatic(min int, max int) { - _m.Called(min, max) -} - -// PublishStatistics provides a mock function with given fields: stats -func (_m *ServerPublisher) PublishStatistics(stats *actions.RunnerScaleSetStatistic) { - _m.Called(stats) -} - // NewServerPublisher creates a new instance of ServerPublisher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewServerPublisher(t interface { @@ -67,3 +24,273 @@ func NewServerPublisher(t interface { return mock } + +// ServerPublisher is an autogenerated mock type for the ServerExporter type +type ServerPublisher struct { + mock.Mock +} + +type ServerPublisher_Expecter struct { + mock *mock.Mock +} + +func (_m *ServerPublisher) EXPECT() *ServerPublisher_Expecter { + return &ServerPublisher_Expecter{mock: &_m.Mock} +} + +// ListenAndServe provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) ListenAndServe(ctx context.Context) error { + ret := _mock.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for ListenAndServe") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok { + r0 = returnFunc(ctx) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// ServerPublisher_ListenAndServe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListenAndServe' +type ServerPublisher_ListenAndServe_Call struct { + *mock.Call +} + +// ListenAndServe is a helper method to define mock.On call +// - ctx context.Context +func (_e *ServerPublisher_Expecter) ListenAndServe(ctx interface{}) *ServerPublisher_ListenAndServe_Call { + return &ServerPublisher_ListenAndServe_Call{Call: _e.mock.On("ListenAndServe", ctx)} +} + +func (_c *ServerPublisher_ListenAndServe_Call) Run(run func(ctx context.Context)) *ServerPublisher_ListenAndServe_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *ServerPublisher_ListenAndServe_Call) Return(err error) *ServerPublisher_ListenAndServe_Call { + _c.Call.Return(err) + return _c +} + +func (_c *ServerPublisher_ListenAndServe_Call) RunAndReturn(run func(ctx context.Context) error) *ServerPublisher_ListenAndServe_Call { + _c.Call.Return(run) + return _c +} + +// PublishDesiredRunners provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) PublishDesiredRunners(count int) { + _mock.Called(count) + return +} + +// ServerPublisher_PublishDesiredRunners_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishDesiredRunners' +type ServerPublisher_PublishDesiredRunners_Call struct { + *mock.Call +} + +// PublishDesiredRunners is a helper method to define mock.On call +// - count int +func (_e *ServerPublisher_Expecter) PublishDesiredRunners(count interface{}) *ServerPublisher_PublishDesiredRunners_Call { + return &ServerPublisher_PublishDesiredRunners_Call{Call: _e.mock.On("PublishDesiredRunners", count)} +} + +func (_c *ServerPublisher_PublishDesiredRunners_Call) Run(run func(count int)) *ServerPublisher_PublishDesiredRunners_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *ServerPublisher_PublishDesiredRunners_Call) Return() *ServerPublisher_PublishDesiredRunners_Call { + _c.Call.Return() + return _c +} + +func (_c *ServerPublisher_PublishDesiredRunners_Call) RunAndReturn(run func(count int)) *ServerPublisher_PublishDesiredRunners_Call { + _c.Run(run) + return _c +} + +// PublishJobCompleted provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) PublishJobCompleted(msg *actions.JobCompleted) { + _mock.Called(msg) + return +} + +// ServerPublisher_PublishJobCompleted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJobCompleted' +type ServerPublisher_PublishJobCompleted_Call struct { + *mock.Call +} + +// PublishJobCompleted is a helper method to define mock.On call +// - msg *actions.JobCompleted +func (_e *ServerPublisher_Expecter) PublishJobCompleted(msg interface{}) *ServerPublisher_PublishJobCompleted_Call { + return &ServerPublisher_PublishJobCompleted_Call{Call: _e.mock.On("PublishJobCompleted", msg)} +} + +func (_c *ServerPublisher_PublishJobCompleted_Call) Run(run func(msg *actions.JobCompleted)) *ServerPublisher_PublishJobCompleted_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.JobCompleted + if args[0] != nil { + arg0 = args[0].(*actions.JobCompleted) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *ServerPublisher_PublishJobCompleted_Call) Return() *ServerPublisher_PublishJobCompleted_Call { + _c.Call.Return() + return _c +} + +func (_c *ServerPublisher_PublishJobCompleted_Call) RunAndReturn(run func(msg *actions.JobCompleted)) *ServerPublisher_PublishJobCompleted_Call { + _c.Run(run) + return _c +} + +// PublishJobStarted provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) PublishJobStarted(msg *actions.JobStarted) { + _mock.Called(msg) + return +} + +// ServerPublisher_PublishJobStarted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishJobStarted' +type ServerPublisher_PublishJobStarted_Call struct { + *mock.Call +} + +// PublishJobStarted is a helper method to define mock.On call +// - msg *actions.JobStarted +func (_e *ServerPublisher_Expecter) PublishJobStarted(msg interface{}) *ServerPublisher_PublishJobStarted_Call { + return &ServerPublisher_PublishJobStarted_Call{Call: _e.mock.On("PublishJobStarted", msg)} +} + +func (_c *ServerPublisher_PublishJobStarted_Call) Run(run func(msg *actions.JobStarted)) *ServerPublisher_PublishJobStarted_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.JobStarted + if args[0] != nil { + arg0 = args[0].(*actions.JobStarted) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *ServerPublisher_PublishJobStarted_Call) Return() *ServerPublisher_PublishJobStarted_Call { + _c.Call.Return() + return _c +} + +func (_c *ServerPublisher_PublishJobStarted_Call) RunAndReturn(run func(msg *actions.JobStarted)) *ServerPublisher_PublishJobStarted_Call { + _c.Run(run) + return _c +} + +// PublishStatic provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) PublishStatic(min int, max int) { + _mock.Called(min, max) + return +} + +// ServerPublisher_PublishStatic_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishStatic' +type ServerPublisher_PublishStatic_Call struct { + *mock.Call +} + +// PublishStatic is a helper method to define mock.On call +// - min int +// - max int +func (_e *ServerPublisher_Expecter) PublishStatic(min interface{}, max interface{}) *ServerPublisher_PublishStatic_Call { + return &ServerPublisher_PublishStatic_Call{Call: _e.mock.On("PublishStatic", min, max)} +} + +func (_c *ServerPublisher_PublishStatic_Call) Run(run func(min int, max int)) *ServerPublisher_PublishStatic_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 int + if args[0] != nil { + arg0 = args[0].(int) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *ServerPublisher_PublishStatic_Call) Return() *ServerPublisher_PublishStatic_Call { + _c.Call.Return() + return _c +} + +func (_c *ServerPublisher_PublishStatic_Call) RunAndReturn(run func(min int, max int)) *ServerPublisher_PublishStatic_Call { + _c.Run(run) + return _c +} + +// PublishStatistics provides a mock function for the type ServerPublisher +func (_mock *ServerPublisher) PublishStatistics(stats *actions.RunnerScaleSetStatistic) { + _mock.Called(stats) + return +} + +// ServerPublisher_PublishStatistics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishStatistics' +type ServerPublisher_PublishStatistics_Call struct { + *mock.Call +} + +// PublishStatistics is a helper method to define mock.On call +// - stats *actions.RunnerScaleSetStatistic +func (_e *ServerPublisher_Expecter) PublishStatistics(stats interface{}) *ServerPublisher_PublishStatistics_Call { + return &ServerPublisher_PublishStatistics_Call{Call: _e.mock.On("PublishStatistics", stats)} +} + +func (_c *ServerPublisher_PublishStatistics_Call) Run(run func(stats *actions.RunnerScaleSetStatistic)) *ServerPublisher_PublishStatistics_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 *actions.RunnerScaleSetStatistic + if args[0] != nil { + arg0 = args[0].(*actions.RunnerScaleSetStatistic) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *ServerPublisher_PublishStatistics_Call) Return() *ServerPublisher_PublishStatistics_Call { + _c.Call.Return() + return _c +} + +func (_c *ServerPublisher_PublishStatistics_Call) RunAndReturn(run func(stats *actions.RunnerScaleSetStatistic)) *ServerPublisher_PublishStatistics_Call { + _c.Run(run) + return _c +} diff --git a/github/actions/client.go b/github/actions/client.go index 77d27cbb..adcab700 100644 --- a/github/actions/client.go +++ b/github/actions/client.go @@ -34,7 +34,7 @@ const ( // Header used to propagate capacity information to the back-end const HeaderScaleSetMaxCapacity = "X-ScaleSetMaxCapacity" -//go:generate mockery --inpackage --name=ActionsService +//go:generate mockery type ActionsService interface { GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error) GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error) diff --git a/github/actions/mock_ActionsService.go b/github/actions/mock_ActionsService.go deleted file mode 100644 index 849f2c19..00000000 --- a/github/actions/mock_ActionsService.go +++ /dev/null @@ -1,428 +0,0 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. - -package actions - -import ( - context "context" - - uuid "github.com/google/uuid" - mock "github.com/stretchr/testify/mock" -) - -// MockActionsService is an autogenerated mock type for the ActionsService type -type MockActionsService struct { - mock.Mock -} - -// AcquireJobs provides a mock function with given fields: ctx, runnerScaleSetId, messageQueueAccessToken, requestIds -func (_m *MockActionsService) AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error) { - ret := _m.Called(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) - - var r0 []int64 - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, string, []int64) ([]int64, error)); ok { - return rf(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) - } - if rf, ok := ret.Get(0).(func(context.Context, int, string, []int64) []int64); ok { - r0 = rf(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int64) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int, string, []int64) error); ok { - r1 = rf(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreateMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, owner -func (_m *MockActionsService) CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error) { - ret := _m.Called(ctx, runnerScaleSetId, owner) - - var r0 *RunnerScaleSetSession - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, string) (*RunnerScaleSetSession, error)); ok { - return rf(ctx, runnerScaleSetId, owner) - } - if rf, ok := ret.Get(0).(func(context.Context, int, string) *RunnerScaleSetSession); ok { - r0 = rf(ctx, runnerScaleSetId, owner) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSetSession) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int, string) error); ok { - r1 = rf(ctx, runnerScaleSetId, owner) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// CreateRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSet -func (_m *MockActionsService) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error) { - ret := _m.Called(ctx, runnerScaleSet) - - var r0 *RunnerScaleSet - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *RunnerScaleSet) (*RunnerScaleSet, error)); ok { - return rf(ctx, runnerScaleSet) - } - if rf, ok := ret.Get(0).(func(context.Context, *RunnerScaleSet) *RunnerScaleSet); ok { - r0 = rf(ctx, runnerScaleSet) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSet) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *RunnerScaleSet) error); ok { - r1 = rf(ctx, runnerScaleSet) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// DeleteMessage provides a mock function with given fields: ctx, messageQueueUrl, messageQueueAccessToken, messageId -func (_m *MockActionsService) DeleteMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, messageId int64) error { - ret := _m.Called(ctx, messageQueueUrl, messageQueueAccessToken, messageId) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) error); ok { - r0 = rf(ctx, messageQueueUrl, messageQueueAccessToken, messageId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// DeleteMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, sessionId -func (_m *MockActionsService) DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error { - ret := _m.Called(ctx, runnerScaleSetId, sessionId) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) error); ok { - r0 = rf(ctx, runnerScaleSetId, sessionId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// DeleteRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSetId -func (_m *MockActionsService) DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error { - ret := _m.Called(ctx, runnerScaleSetId) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int) error); ok { - r0 = rf(ctx, runnerScaleSetId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GenerateJitRunnerConfig provides a mock function with given fields: ctx, jitRunnerSetting, scaleSetId -func (_m *MockActionsService) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error) { - ret := _m.Called(ctx, jitRunnerSetting, scaleSetId) - - var r0 *RunnerScaleSetJitRunnerConfig - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) (*RunnerScaleSetJitRunnerConfig, error)); ok { - return rf(ctx, jitRunnerSetting, scaleSetId) - } - if rf, ok := ret.Get(0).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) *RunnerScaleSetJitRunnerConfig); ok { - r0 = rf(ctx, jitRunnerSetting, scaleSetId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSetJitRunnerConfig) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) error); ok { - r1 = rf(ctx, jitRunnerSetting, scaleSetId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetAcquirableJobs provides a mock function with given fields: ctx, runnerScaleSetId -func (_m *MockActionsService) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error) { - ret := _m.Called(ctx, runnerScaleSetId) - - var r0 *AcquirableJobList - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int) (*AcquirableJobList, error)); ok { - return rf(ctx, runnerScaleSetId) - } - if rf, ok := ret.Get(0).(func(context.Context, int) *AcquirableJobList); ok { - r0 = rf(ctx, runnerScaleSetId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*AcquirableJobList) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int) error); ok { - r1 = rf(ctx, runnerScaleSetId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetMessage provides a mock function with given fields: ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity -func (_m *MockActionsService) GetMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error) { - ret := _m.Called(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) - - var r0 *RunnerScaleSetMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, int) (*RunnerScaleSetMessage, error)); ok { - return rf(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, int) *RunnerScaleSetMessage); ok { - r0 = rf(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSetMessage) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, int64, int) error); ok { - r1 = rf(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRunner provides a mock function with given fields: ctx, runnerId -func (_m *MockActionsService) GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error) { - ret := _m.Called(ctx, runnerId) - - var r0 *RunnerReference - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64) (*RunnerReference, error)); ok { - return rf(ctx, runnerId) - } - if rf, ok := ret.Get(0).(func(context.Context, int64) *RunnerReference); ok { - r0 = rf(ctx, runnerId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerReference) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { - r1 = rf(ctx, runnerId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRunnerByName provides a mock function with given fields: ctx, runnerName -func (_m *MockActionsService) GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error) { - ret := _m.Called(ctx, runnerName) - - var r0 *RunnerReference - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*RunnerReference, error)); ok { - return rf(ctx, runnerName) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *RunnerReference); ok { - r0 = rf(ctx, runnerName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerReference) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, runnerName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRunnerGroupByName provides a mock function with given fields: ctx, runnerGroup -func (_m *MockActionsService) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error) { - ret := _m.Called(ctx, runnerGroup) - - var r0 *RunnerGroup - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*RunnerGroup, error)); ok { - return rf(ctx, runnerGroup) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *RunnerGroup); ok { - r0 = rf(ctx, runnerGroup) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerGroup) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, runnerGroup) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRunnerScaleSet provides a mock function with given fields: ctx, runnerGroupId, runnerScaleSetName -func (_m *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error) { - ret := _m.Called(ctx, runnerGroupId, runnerScaleSetName) - - var r0 *RunnerScaleSet - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, string) (*RunnerScaleSet, error)); ok { - return rf(ctx, runnerGroupId, runnerScaleSetName) - } - if rf, ok := ret.Get(0).(func(context.Context, int, string) *RunnerScaleSet); ok { - r0 = rf(ctx, runnerGroupId, runnerScaleSetName) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSet) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int, string) error); ok { - r1 = rf(ctx, runnerGroupId, runnerScaleSetName) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetRunnerScaleSetById provides a mock function with given fields: ctx, runnerScaleSetId -func (_m *MockActionsService) GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error) { - ret := _m.Called(ctx, runnerScaleSetId) - - var r0 *RunnerScaleSet - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int) (*RunnerScaleSet, error)); ok { - return rf(ctx, runnerScaleSetId) - } - if rf, ok := ret.Get(0).(func(context.Context, int) *RunnerScaleSet); ok { - r0 = rf(ctx, runnerScaleSetId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSet) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int) error); ok { - r1 = rf(ctx, runnerScaleSetId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RefreshMessageSession provides a mock function with given fields: ctx, runnerScaleSetId, sessionId -func (_m *MockActionsService) RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error) { - ret := _m.Called(ctx, runnerScaleSetId, sessionId) - - var r0 *RunnerScaleSetSession - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) (*RunnerScaleSetSession, error)); ok { - return rf(ctx, runnerScaleSetId, sessionId) - } - if rf, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) *RunnerScaleSetSession); ok { - r0 = rf(ctx, runnerScaleSetId, sessionId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSetSession) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int, *uuid.UUID) error); ok { - r1 = rf(ctx, runnerScaleSetId, sessionId) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// RemoveRunner provides a mock function with given fields: ctx, runnerId -func (_m *MockActionsService) RemoveRunner(ctx context.Context, runnerId int64) error { - ret := _m.Called(ctx, runnerId) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { - r0 = rf(ctx, runnerId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetUserAgent provides a mock function with given fields: info -func (_m *MockActionsService) SetUserAgent(info UserAgentInfo) { - _m.Called(info) -} - -// UpdateRunnerScaleSet provides a mock function with given fields: ctx, runnerScaleSetId, runnerScaleSet -func (_m *MockActionsService) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error) { - ret := _m.Called(ctx, runnerScaleSetId, runnerScaleSet) - - var r0 *RunnerScaleSet - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int, *RunnerScaleSet) (*RunnerScaleSet, error)); ok { - return rf(ctx, runnerScaleSetId, runnerScaleSet) - } - if rf, ok := ret.Get(0).(func(context.Context, int, *RunnerScaleSet) *RunnerScaleSet); ok { - r0 = rf(ctx, runnerScaleSetId, runnerScaleSet) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSet) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int, *RunnerScaleSet) error); ok { - r1 = rf(ctx, runnerScaleSetId, runnerScaleSet) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewMockActionsService creates a new instance of MockActionsService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockActionsService(t interface { - mock.TestingT - Cleanup(func()) -}) *MockActionsService { - mock := &MockActionsService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/github/actions/mock_SessionService.go b/github/actions/mock_SessionService.go deleted file mode 100644 index f587cac8..00000000 --- a/github/actions/mock_SessionService.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by mockery v2.36.1. DO NOT EDIT. - -package actions - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockSessionService is an autogenerated mock type for the SessionService type -type MockSessionService struct { - mock.Mock -} - -// AcquireJobs provides a mock function with given fields: ctx, requestIds -func (_m *MockSessionService) AcquireJobs(ctx context.Context, requestIds []int64) ([]int64, error) { - ret := _m.Called(ctx, requestIds) - - var r0 []int64 - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []int64) ([]int64, error)); ok { - return rf(ctx, requestIds) - } - if rf, ok := ret.Get(0).(func(context.Context, []int64) []int64); ok { - r0 = rf(ctx, requestIds) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]int64) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, []int64) error); ok { - r1 = rf(ctx, requestIds) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Close provides a mock function with given fields: -func (_m *MockSessionService) Close() error { - ret := _m.Called() - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// DeleteMessage provides a mock function with given fields: ctx, messageId -func (_m *MockSessionService) DeleteMessage(ctx context.Context, messageId int64) error { - ret := _m.Called(ctx, messageId) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { - r0 = rf(ctx, messageId) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// GetMessage provides a mock function with given fields: ctx, lastMessageId, maxCapacity -func (_m *MockSessionService) GetMessage(ctx context.Context, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error) { - ret := _m.Called(ctx, lastMessageId, maxCapacity) - - var r0 *RunnerScaleSetMessage - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, int64, int) (*RunnerScaleSetMessage, error)); ok { - return rf(ctx, lastMessageId, maxCapacity) - } - if rf, ok := ret.Get(0).(func(context.Context, int64, int) *RunnerScaleSetMessage); ok { - r0 = rf(ctx, lastMessageId, maxCapacity) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*RunnerScaleSetMessage) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, int64, int) error); ok { - r1 = rf(ctx, lastMessageId, maxCapacity) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// NewMockSessionService creates a new instance of MockSessionService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewMockSessionService(t interface { - mock.TestingT - Cleanup(func()) -}) *MockSessionService { - mock := &MockSessionService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/github/actions/mocks_test.go b/github/actions/mocks_test.go new file mode 100644 index 00000000..204236df --- /dev/null +++ b/github/actions/mocks_test.go @@ -0,0 +1,1539 @@ +// Code generated by mockery; DO NOT EDIT. +// github.com/vektra/mockery +// template: testify + +package actions + +import ( + "context" + + "github.com/google/uuid" + mock "github.com/stretchr/testify/mock" +) + +// NewMockActionsService creates a new instance of MockActionsService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockActionsService(t interface { + mock.TestingT + Cleanup(func()) +}) *MockActionsService { + mock := &MockActionsService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockActionsService is an autogenerated mock type for the ActionsService type +type MockActionsService struct { + mock.Mock +} + +type MockActionsService_Expecter struct { + mock *mock.Mock +} + +func (_m *MockActionsService) EXPECT() *MockActionsService_Expecter { + return &MockActionsService_Expecter{mock: &_m.Mock} +} + +// AcquireJobs provides a mock function for the type MockActionsService +func (_mock *MockActionsService) AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error) { + ret := _mock.Called(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) + + if len(ret) == 0 { + panic("no return value specified for AcquireJobs") + } + + var r0 []int64 + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string, []int64) ([]int64, error)); ok { + return returnFunc(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string, []int64) []int64); ok { + r0 = returnFunc(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]int64) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, string, []int64) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId, messageQueueAccessToken, requestIds) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_AcquireJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AcquireJobs' +type MockActionsService_AcquireJobs_Call struct { + *mock.Call +} + +// AcquireJobs is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +// - messageQueueAccessToken string +// - requestIds []int64 +func (_e *MockActionsService_Expecter) AcquireJobs(ctx interface{}, runnerScaleSetId interface{}, messageQueueAccessToken interface{}, requestIds interface{}) *MockActionsService_AcquireJobs_Call { + return &MockActionsService_AcquireJobs_Call{Call: _e.mock.On("AcquireJobs", ctx, runnerScaleSetId, messageQueueAccessToken, requestIds)} +} + +func (_c *MockActionsService_AcquireJobs_Call) Run(run func(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64)) *MockActionsService_AcquireJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 []int64 + if args[3] != nil { + arg3 = args[3].([]int64) + } + run( + arg0, + arg1, + arg2, + arg3, + ) + }) + return _c +} + +func (_c *MockActionsService_AcquireJobs_Call) Return(int64s []int64, err error) *MockActionsService_AcquireJobs_Call { + _c.Call.Return(int64s, err) + return _c +} + +func (_c *MockActionsService_AcquireJobs_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)) *MockActionsService_AcquireJobs_Call { + _c.Call.Return(run) + return _c +} + +// CreateMessageSession provides a mock function for the type MockActionsService +func (_mock *MockActionsService) CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error) { + ret := _mock.Called(ctx, runnerScaleSetId, owner) + + if len(ret) == 0 { + panic("no return value specified for CreateMessageSession") + } + + var r0 *RunnerScaleSetSession + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string) (*RunnerScaleSetSession, error)); ok { + return returnFunc(ctx, runnerScaleSetId, owner) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string) *RunnerScaleSetSession); ok { + r0 = returnFunc(ctx, runnerScaleSetId, owner) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSetSession) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, string) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId, owner) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_CreateMessageSession_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMessageSession' +type MockActionsService_CreateMessageSession_Call struct { + *mock.Call +} + +// CreateMessageSession is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +// - owner string +func (_e *MockActionsService_Expecter) CreateMessageSession(ctx interface{}, runnerScaleSetId interface{}, owner interface{}) *MockActionsService_CreateMessageSession_Call { + return &MockActionsService_CreateMessageSession_Call{Call: _e.mock.On("CreateMessageSession", ctx, runnerScaleSetId, owner)} +} + +func (_c *MockActionsService_CreateMessageSession_Call) Run(run func(ctx context.Context, runnerScaleSetId int, owner string)) *MockActionsService_CreateMessageSession_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_CreateMessageSession_Call) Return(runnerScaleSetSession *RunnerScaleSetSession, err error) *MockActionsService_CreateMessageSession_Call { + _c.Call.Return(runnerScaleSetSession, err) + return _c +} + +func (_c *MockActionsService_CreateMessageSession_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error)) *MockActionsService_CreateMessageSession_Call { + _c.Call.Return(run) + return _c +} + +// CreateRunnerScaleSet provides a mock function for the type MockActionsService +func (_mock *MockActionsService) CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error) { + ret := _mock.Called(ctx, runnerScaleSet) + + if len(ret) == 0 { + panic("no return value specified for CreateRunnerScaleSet") + } + + var r0 *RunnerScaleSet + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *RunnerScaleSet) (*RunnerScaleSet, error)); ok { + return returnFunc(ctx, runnerScaleSet) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, *RunnerScaleSet) *RunnerScaleSet); ok { + r0 = returnFunc(ctx, runnerScaleSet) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSet) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, *RunnerScaleSet) error); ok { + r1 = returnFunc(ctx, runnerScaleSet) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_CreateRunnerScaleSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRunnerScaleSet' +type MockActionsService_CreateRunnerScaleSet_Call struct { + *mock.Call +} + +// CreateRunnerScaleSet is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSet *RunnerScaleSet +func (_e *MockActionsService_Expecter) CreateRunnerScaleSet(ctx interface{}, runnerScaleSet interface{}) *MockActionsService_CreateRunnerScaleSet_Call { + return &MockActionsService_CreateRunnerScaleSet_Call{Call: _e.mock.On("CreateRunnerScaleSet", ctx, runnerScaleSet)} +} + +func (_c *MockActionsService_CreateRunnerScaleSet_Call) Run(run func(ctx context.Context, runnerScaleSet *RunnerScaleSet)) *MockActionsService_CreateRunnerScaleSet_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *RunnerScaleSet + if args[1] != nil { + arg1 = args[1].(*RunnerScaleSet) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_CreateRunnerScaleSet_Call) Return(runnerScaleSet1 *RunnerScaleSet, err error) *MockActionsService_CreateRunnerScaleSet_Call { + _c.Call.Return(runnerScaleSet1, err) + return _c +} + +func (_c *MockActionsService_CreateRunnerScaleSet_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)) *MockActionsService_CreateRunnerScaleSet_Call { + _c.Call.Return(run) + return _c +} + +// DeleteMessage provides a mock function for the type MockActionsService +func (_mock *MockActionsService) DeleteMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, messageId int64) error { + ret := _mock.Called(ctx, messageQueueUrl, messageQueueAccessToken, messageId) + + if len(ret) == 0 { + panic("no return value specified for DeleteMessage") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, int64) error); ok { + r0 = returnFunc(ctx, messageQueueUrl, messageQueueAccessToken, messageId) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockActionsService_DeleteMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteMessage' +type MockActionsService_DeleteMessage_Call struct { + *mock.Call +} + +// DeleteMessage is a helper method to define mock.On call +// - ctx context.Context +// - messageQueueUrl string +// - messageQueueAccessToken string +// - messageId int64 +func (_e *MockActionsService_Expecter) DeleteMessage(ctx interface{}, messageQueueUrl interface{}, messageQueueAccessToken interface{}, messageId interface{}) *MockActionsService_DeleteMessage_Call { + return &MockActionsService_DeleteMessage_Call{Call: _e.mock.On("DeleteMessage", ctx, messageQueueUrl, messageQueueAccessToken, messageId)} +} + +func (_c *MockActionsService_DeleteMessage_Call) Run(run func(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, messageId int64)) *MockActionsService_DeleteMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 int64 + if args[3] != nil { + arg3 = args[3].(int64) + } + run( + arg0, + arg1, + arg2, + arg3, + ) + }) + return _c +} + +func (_c *MockActionsService_DeleteMessage_Call) Return(err error) *MockActionsService_DeleteMessage_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockActionsService_DeleteMessage_Call) RunAndReturn(run func(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, messageId int64) error) *MockActionsService_DeleteMessage_Call { + _c.Call.Return(run) + return _c +} + +// DeleteMessageSession provides a mock function for the type MockActionsService +func (_mock *MockActionsService) DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error { + ret := _mock.Called(ctx, runnerScaleSetId, sessionId) + + if len(ret) == 0 { + panic("no return value specified for DeleteMessageSession") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) error); ok { + r0 = returnFunc(ctx, runnerScaleSetId, sessionId) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockActionsService_DeleteMessageSession_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteMessageSession' +type MockActionsService_DeleteMessageSession_Call struct { + *mock.Call +} + +// DeleteMessageSession is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +// - sessionId *uuid.UUID +func (_e *MockActionsService_Expecter) DeleteMessageSession(ctx interface{}, runnerScaleSetId interface{}, sessionId interface{}) *MockActionsService_DeleteMessageSession_Call { + return &MockActionsService_DeleteMessageSession_Call{Call: _e.mock.On("DeleteMessageSession", ctx, runnerScaleSetId, sessionId)} +} + +func (_c *MockActionsService_DeleteMessageSession_Call) Run(run func(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID)) *MockActionsService_DeleteMessageSession_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 *uuid.UUID + if args[2] != nil { + arg2 = args[2].(*uuid.UUID) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_DeleteMessageSession_Call) Return(err error) *MockActionsService_DeleteMessageSession_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockActionsService_DeleteMessageSession_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error) *MockActionsService_DeleteMessageSession_Call { + _c.Call.Return(run) + return _c +} + +// DeleteRunnerScaleSet provides a mock function for the type MockActionsService +func (_mock *MockActionsService) DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error { + ret := _mock.Called(ctx, runnerScaleSetId) + + if len(ret) == 0 { + panic("no return value specified for DeleteRunnerScaleSet") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int) error); ok { + r0 = returnFunc(ctx, runnerScaleSetId) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockActionsService_DeleteRunnerScaleSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteRunnerScaleSet' +type MockActionsService_DeleteRunnerScaleSet_Call struct { + *mock.Call +} + +// DeleteRunnerScaleSet is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +func (_e *MockActionsService_Expecter) DeleteRunnerScaleSet(ctx interface{}, runnerScaleSetId interface{}) *MockActionsService_DeleteRunnerScaleSet_Call { + return &MockActionsService_DeleteRunnerScaleSet_Call{Call: _e.mock.On("DeleteRunnerScaleSet", ctx, runnerScaleSetId)} +} + +func (_c *MockActionsService_DeleteRunnerScaleSet_Call) Run(run func(ctx context.Context, runnerScaleSetId int)) *MockActionsService_DeleteRunnerScaleSet_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_DeleteRunnerScaleSet_Call) Return(err error) *MockActionsService_DeleteRunnerScaleSet_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockActionsService_DeleteRunnerScaleSet_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int) error) *MockActionsService_DeleteRunnerScaleSet_Call { + _c.Call.Return(run) + return _c +} + +// GenerateJitRunnerConfig provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error) { + ret := _mock.Called(ctx, jitRunnerSetting, scaleSetId) + + if len(ret) == 0 { + panic("no return value specified for GenerateJitRunnerConfig") + } + + var r0 *RunnerScaleSetJitRunnerConfig + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) (*RunnerScaleSetJitRunnerConfig, error)); ok { + return returnFunc(ctx, jitRunnerSetting, scaleSetId) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) *RunnerScaleSetJitRunnerConfig); ok { + r0 = returnFunc(ctx, jitRunnerSetting, scaleSetId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSetJitRunnerConfig) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, *RunnerScaleSetJitRunnerSetting, int) error); ok { + r1 = returnFunc(ctx, jitRunnerSetting, scaleSetId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GenerateJitRunnerConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateJitRunnerConfig' +type MockActionsService_GenerateJitRunnerConfig_Call struct { + *mock.Call +} + +// GenerateJitRunnerConfig is a helper method to define mock.On call +// - ctx context.Context +// - jitRunnerSetting *RunnerScaleSetJitRunnerSetting +// - scaleSetId int +func (_e *MockActionsService_Expecter) GenerateJitRunnerConfig(ctx interface{}, jitRunnerSetting interface{}, scaleSetId interface{}) *MockActionsService_GenerateJitRunnerConfig_Call { + return &MockActionsService_GenerateJitRunnerConfig_Call{Call: _e.mock.On("GenerateJitRunnerConfig", ctx, jitRunnerSetting, scaleSetId)} +} + +func (_c *MockActionsService_GenerateJitRunnerConfig_Call) Run(run func(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int)) *MockActionsService_GenerateJitRunnerConfig_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 *RunnerScaleSetJitRunnerSetting + if args[1] != nil { + arg1 = args[1].(*RunnerScaleSetJitRunnerSetting) + } + var arg2 int + if args[2] != nil { + arg2 = args[2].(int) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_GenerateJitRunnerConfig_Call) Return(runnerScaleSetJitRunnerConfig *RunnerScaleSetJitRunnerConfig, err error) *MockActionsService_GenerateJitRunnerConfig_Call { + _c.Call.Return(runnerScaleSetJitRunnerConfig, err) + return _c +} + +func (_c *MockActionsService_GenerateJitRunnerConfig_Call) RunAndReturn(run func(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error)) *MockActionsService_GenerateJitRunnerConfig_Call { + _c.Call.Return(run) + return _c +} + +// GetAcquirableJobs provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error) { + ret := _mock.Called(ctx, runnerScaleSetId) + + if len(ret) == 0 { + panic("no return value specified for GetAcquirableJobs") + } + + var r0 *AcquirableJobList + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int) (*AcquirableJobList, error)); ok { + return returnFunc(ctx, runnerScaleSetId) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int) *AcquirableJobList); ok { + r0 = returnFunc(ctx, runnerScaleSetId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*AcquirableJobList) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetAcquirableJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAcquirableJobs' +type MockActionsService_GetAcquirableJobs_Call struct { + *mock.Call +} + +// GetAcquirableJobs is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +func (_e *MockActionsService_Expecter) GetAcquirableJobs(ctx interface{}, runnerScaleSetId interface{}) *MockActionsService_GetAcquirableJobs_Call { + return &MockActionsService_GetAcquirableJobs_Call{Call: _e.mock.On("GetAcquirableJobs", ctx, runnerScaleSetId)} +} + +func (_c *MockActionsService_GetAcquirableJobs_Call) Run(run func(ctx context.Context, runnerScaleSetId int)) *MockActionsService_GetAcquirableJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_GetAcquirableJobs_Call) Return(acquirableJobList *AcquirableJobList, err error) *MockActionsService_GetAcquirableJobs_Call { + _c.Call.Return(acquirableJobList, err) + return _c +} + +func (_c *MockActionsService_GetAcquirableJobs_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error)) *MockActionsService_GetAcquirableJobs_Call { + _c.Call.Return(run) + return _c +} + +// GetMessage provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetMessage(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error) { + ret := _mock.Called(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) + + if len(ret) == 0 { + panic("no return value specified for GetMessage") + } + + var r0 *RunnerScaleSetMessage + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, int64, int) (*RunnerScaleSetMessage, error)); ok { + return returnFunc(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, int64, int) *RunnerScaleSetMessage); ok { + r0 = returnFunc(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSetMessage) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, string, string, int64, int) error); ok { + r1 = returnFunc(ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessage' +type MockActionsService_GetMessage_Call struct { + *mock.Call +} + +// GetMessage is a helper method to define mock.On call +// - ctx context.Context +// - messageQueueUrl string +// - messageQueueAccessToken string +// - lastMessageId int64 +// - maxCapacity int +func (_e *MockActionsService_Expecter) GetMessage(ctx interface{}, messageQueueUrl interface{}, messageQueueAccessToken interface{}, lastMessageId interface{}, maxCapacity interface{}) *MockActionsService_GetMessage_Call { + return &MockActionsService_GetMessage_Call{Call: _e.mock.On("GetMessage", ctx, messageQueueUrl, messageQueueAccessToken, lastMessageId, maxCapacity)} +} + +func (_c *MockActionsService_GetMessage_Call) Run(run func(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, lastMessageId int64, maxCapacity int)) *MockActionsService_GetMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + var arg3 int64 + if args[3] != nil { + arg3 = args[3].(int64) + } + var arg4 int + if args[4] != nil { + arg4 = args[4].(int) + } + run( + arg0, + arg1, + arg2, + arg3, + arg4, + ) + }) + return _c +} + +func (_c *MockActionsService_GetMessage_Call) Return(runnerScaleSetMessage *RunnerScaleSetMessage, err error) *MockActionsService_GetMessage_Call { + _c.Call.Return(runnerScaleSetMessage, err) + return _c +} + +func (_c *MockActionsService_GetMessage_Call) RunAndReturn(run func(ctx context.Context, messageQueueUrl string, messageQueueAccessToken string, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error)) *MockActionsService_GetMessage_Call { + _c.Call.Return(run) + return _c +} + +// GetRunner provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error) { + ret := _mock.Called(ctx, runnerId) + + if len(ret) == 0 { + panic("no return value specified for GetRunner") + } + + var r0 *RunnerReference + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int64) (*RunnerReference, error)); ok { + return returnFunc(ctx, runnerId) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int64) *RunnerReference); ok { + r0 = returnFunc(ctx, runnerId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerReference) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = returnFunc(ctx, runnerId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetRunner_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunner' +type MockActionsService_GetRunner_Call struct { + *mock.Call +} + +// GetRunner is a helper method to define mock.On call +// - ctx context.Context +// - runnerId int64 +func (_e *MockActionsService_Expecter) GetRunner(ctx interface{}, runnerId interface{}) *MockActionsService_GetRunner_Call { + return &MockActionsService_GetRunner_Call{Call: _e.mock.On("GetRunner", ctx, runnerId)} +} + +func (_c *MockActionsService_GetRunner_Call) Run(run func(ctx context.Context, runnerId int64)) *MockActionsService_GetRunner_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int64 + if args[1] != nil { + arg1 = args[1].(int64) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_GetRunner_Call) Return(runnerReference *RunnerReference, err error) *MockActionsService_GetRunner_Call { + _c.Call.Return(runnerReference, err) + return _c +} + +func (_c *MockActionsService_GetRunner_Call) RunAndReturn(run func(ctx context.Context, runnerId int64) (*RunnerReference, error)) *MockActionsService_GetRunner_Call { + _c.Call.Return(run) + return _c +} + +// GetRunnerByName provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error) { + ret := _mock.Called(ctx, runnerName) + + if len(ret) == 0 { + panic("no return value specified for GetRunnerByName") + } + + var r0 *RunnerReference + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*RunnerReference, error)); ok { + return returnFunc(ctx, runnerName) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, string) *RunnerReference); ok { + r0 = returnFunc(ctx, runnerName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerReference) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = returnFunc(ctx, runnerName) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetRunnerByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunnerByName' +type MockActionsService_GetRunnerByName_Call struct { + *mock.Call +} + +// GetRunnerByName is a helper method to define mock.On call +// - ctx context.Context +// - runnerName string +func (_e *MockActionsService_Expecter) GetRunnerByName(ctx interface{}, runnerName interface{}) *MockActionsService_GetRunnerByName_Call { + return &MockActionsService_GetRunnerByName_Call{Call: _e.mock.On("GetRunnerByName", ctx, runnerName)} +} + +func (_c *MockActionsService_GetRunnerByName_Call) Run(run func(ctx context.Context, runnerName string)) *MockActionsService_GetRunnerByName_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_GetRunnerByName_Call) Return(runnerReference *RunnerReference, err error) *MockActionsService_GetRunnerByName_Call { + _c.Call.Return(runnerReference, err) + return _c +} + +func (_c *MockActionsService_GetRunnerByName_Call) RunAndReturn(run func(ctx context.Context, runnerName string) (*RunnerReference, error)) *MockActionsService_GetRunnerByName_Call { + _c.Call.Return(run) + return _c +} + +// GetRunnerGroupByName provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error) { + ret := _mock.Called(ctx, runnerGroup) + + if len(ret) == 0 { + panic("no return value specified for GetRunnerGroupByName") + } + + var r0 *RunnerGroup + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*RunnerGroup, error)); ok { + return returnFunc(ctx, runnerGroup) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, string) *RunnerGroup); ok { + r0 = returnFunc(ctx, runnerGroup) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerGroup) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = returnFunc(ctx, runnerGroup) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetRunnerGroupByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunnerGroupByName' +type MockActionsService_GetRunnerGroupByName_Call struct { + *mock.Call +} + +// GetRunnerGroupByName is a helper method to define mock.On call +// - ctx context.Context +// - runnerGroup string +func (_e *MockActionsService_Expecter) GetRunnerGroupByName(ctx interface{}, runnerGroup interface{}) *MockActionsService_GetRunnerGroupByName_Call { + return &MockActionsService_GetRunnerGroupByName_Call{Call: _e.mock.On("GetRunnerGroupByName", ctx, runnerGroup)} +} + +func (_c *MockActionsService_GetRunnerGroupByName_Call) Run(run func(ctx context.Context, runnerGroup string)) *MockActionsService_GetRunnerGroupByName_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 string + if args[1] != nil { + arg1 = args[1].(string) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_GetRunnerGroupByName_Call) Return(runnerGroup1 *RunnerGroup, err error) *MockActionsService_GetRunnerGroupByName_Call { + _c.Call.Return(runnerGroup1, err) + return _c +} + +func (_c *MockActionsService_GetRunnerGroupByName_Call) RunAndReturn(run func(ctx context.Context, runnerGroup string) (*RunnerGroup, error)) *MockActionsService_GetRunnerGroupByName_Call { + _c.Call.Return(run) + return _c +} + +// GetRunnerScaleSet provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error) { + ret := _mock.Called(ctx, runnerGroupId, runnerScaleSetName) + + if len(ret) == 0 { + panic("no return value specified for GetRunnerScaleSet") + } + + var r0 *RunnerScaleSet + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string) (*RunnerScaleSet, error)); ok { + return returnFunc(ctx, runnerGroupId, runnerScaleSetName) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, string) *RunnerScaleSet); ok { + r0 = returnFunc(ctx, runnerGroupId, runnerScaleSetName) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSet) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, string) error); ok { + r1 = returnFunc(ctx, runnerGroupId, runnerScaleSetName) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetRunnerScaleSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunnerScaleSet' +type MockActionsService_GetRunnerScaleSet_Call struct { + *mock.Call +} + +// GetRunnerScaleSet is a helper method to define mock.On call +// - ctx context.Context +// - runnerGroupId int +// - runnerScaleSetName string +func (_e *MockActionsService_Expecter) GetRunnerScaleSet(ctx interface{}, runnerGroupId interface{}, runnerScaleSetName interface{}) *MockActionsService_GetRunnerScaleSet_Call { + return &MockActionsService_GetRunnerScaleSet_Call{Call: _e.mock.On("GetRunnerScaleSet", ctx, runnerGroupId, runnerScaleSetName)} +} + +func (_c *MockActionsService_GetRunnerScaleSet_Call) Run(run func(ctx context.Context, runnerGroupId int, runnerScaleSetName string)) *MockActionsService_GetRunnerScaleSet_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 string + if args[2] != nil { + arg2 = args[2].(string) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_GetRunnerScaleSet_Call) Return(runnerScaleSet *RunnerScaleSet, err error) *MockActionsService_GetRunnerScaleSet_Call { + _c.Call.Return(runnerScaleSet, err) + return _c +} + +func (_c *MockActionsService_GetRunnerScaleSet_Call) RunAndReturn(run func(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)) *MockActionsService_GetRunnerScaleSet_Call { + _c.Call.Return(run) + return _c +} + +// GetRunnerScaleSetById provides a mock function for the type MockActionsService +func (_mock *MockActionsService) GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error) { + ret := _mock.Called(ctx, runnerScaleSetId) + + if len(ret) == 0 { + panic("no return value specified for GetRunnerScaleSetById") + } + + var r0 *RunnerScaleSet + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int) (*RunnerScaleSet, error)); ok { + return returnFunc(ctx, runnerScaleSetId) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int) *RunnerScaleSet); ok { + r0 = returnFunc(ctx, runnerScaleSetId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSet) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_GetRunnerScaleSetById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRunnerScaleSetById' +type MockActionsService_GetRunnerScaleSetById_Call struct { + *mock.Call +} + +// GetRunnerScaleSetById is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +func (_e *MockActionsService_Expecter) GetRunnerScaleSetById(ctx interface{}, runnerScaleSetId interface{}) *MockActionsService_GetRunnerScaleSetById_Call { + return &MockActionsService_GetRunnerScaleSetById_Call{Call: _e.mock.On("GetRunnerScaleSetById", ctx, runnerScaleSetId)} +} + +func (_c *MockActionsService_GetRunnerScaleSetById_Call) Run(run func(ctx context.Context, runnerScaleSetId int)) *MockActionsService_GetRunnerScaleSetById_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_GetRunnerScaleSetById_Call) Return(runnerScaleSet *RunnerScaleSet, err error) *MockActionsService_GetRunnerScaleSetById_Call { + _c.Call.Return(runnerScaleSet, err) + return _c +} + +func (_c *MockActionsService_GetRunnerScaleSetById_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)) *MockActionsService_GetRunnerScaleSetById_Call { + _c.Call.Return(run) + return _c +} + +// RefreshMessageSession provides a mock function for the type MockActionsService +func (_mock *MockActionsService) RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error) { + ret := _mock.Called(ctx, runnerScaleSetId, sessionId) + + if len(ret) == 0 { + panic("no return value specified for RefreshMessageSession") + } + + var r0 *RunnerScaleSetSession + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) (*RunnerScaleSetSession, error)); ok { + return returnFunc(ctx, runnerScaleSetId, sessionId) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, *uuid.UUID) *RunnerScaleSetSession); ok { + r0 = returnFunc(ctx, runnerScaleSetId, sessionId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSetSession) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, *uuid.UUID) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId, sessionId) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_RefreshMessageSession_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefreshMessageSession' +type MockActionsService_RefreshMessageSession_Call struct { + *mock.Call +} + +// RefreshMessageSession is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +// - sessionId *uuid.UUID +func (_e *MockActionsService_Expecter) RefreshMessageSession(ctx interface{}, runnerScaleSetId interface{}, sessionId interface{}) *MockActionsService_RefreshMessageSession_Call { + return &MockActionsService_RefreshMessageSession_Call{Call: _e.mock.On("RefreshMessageSession", ctx, runnerScaleSetId, sessionId)} +} + +func (_c *MockActionsService_RefreshMessageSession_Call) Run(run func(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID)) *MockActionsService_RefreshMessageSession_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 *uuid.UUID + if args[2] != nil { + arg2 = args[2].(*uuid.UUID) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_RefreshMessageSession_Call) Return(runnerScaleSetSession *RunnerScaleSetSession, err error) *MockActionsService_RefreshMessageSession_Call { + _c.Call.Return(runnerScaleSetSession, err) + return _c +} + +func (_c *MockActionsService_RefreshMessageSession_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error)) *MockActionsService_RefreshMessageSession_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRunner provides a mock function for the type MockActionsService +func (_mock *MockActionsService) RemoveRunner(ctx context.Context, runnerId int64) error { + ret := _mock.Called(ctx, runnerId) + + if len(ret) == 0 { + panic("no return value specified for RemoveRunner") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = returnFunc(ctx, runnerId) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockActionsService_RemoveRunner_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRunner' +type MockActionsService_RemoveRunner_Call struct { + *mock.Call +} + +// RemoveRunner is a helper method to define mock.On call +// - ctx context.Context +// - runnerId int64 +func (_e *MockActionsService_Expecter) RemoveRunner(ctx interface{}, runnerId interface{}) *MockActionsService_RemoveRunner_Call { + return &MockActionsService_RemoveRunner_Call{Call: _e.mock.On("RemoveRunner", ctx, runnerId)} +} + +func (_c *MockActionsService_RemoveRunner_Call) Run(run func(ctx context.Context, runnerId int64)) *MockActionsService_RemoveRunner_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int64 + if args[1] != nil { + arg1 = args[1].(int64) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockActionsService_RemoveRunner_Call) Return(err error) *MockActionsService_RemoveRunner_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockActionsService_RemoveRunner_Call) RunAndReturn(run func(ctx context.Context, runnerId int64) error) *MockActionsService_RemoveRunner_Call { + _c.Call.Return(run) + return _c +} + +// SetUserAgent provides a mock function for the type MockActionsService +func (_mock *MockActionsService) SetUserAgent(info UserAgentInfo) { + _mock.Called(info) + return +} + +// MockActionsService_SetUserAgent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUserAgent' +type MockActionsService_SetUserAgent_Call struct { + *mock.Call +} + +// SetUserAgent is a helper method to define mock.On call +// - info UserAgentInfo +func (_e *MockActionsService_Expecter) SetUserAgent(info interface{}) *MockActionsService_SetUserAgent_Call { + return &MockActionsService_SetUserAgent_Call{Call: _e.mock.On("SetUserAgent", info)} +} + +func (_c *MockActionsService_SetUserAgent_Call) Run(run func(info UserAgentInfo)) *MockActionsService_SetUserAgent_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 UserAgentInfo + if args[0] != nil { + arg0 = args[0].(UserAgentInfo) + } + run( + arg0, + ) + }) + return _c +} + +func (_c *MockActionsService_SetUserAgent_Call) Return() *MockActionsService_SetUserAgent_Call { + _c.Call.Return() + return _c +} + +func (_c *MockActionsService_SetUserAgent_Call) RunAndReturn(run func(info UserAgentInfo)) *MockActionsService_SetUserAgent_Call { + _c.Run(run) + return _c +} + +// UpdateRunnerScaleSet provides a mock function for the type MockActionsService +func (_mock *MockActionsService) UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error) { + ret := _mock.Called(ctx, runnerScaleSetId, runnerScaleSet) + + if len(ret) == 0 { + panic("no return value specified for UpdateRunnerScaleSet") + } + + var r0 *RunnerScaleSet + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int, *RunnerScaleSet) (*RunnerScaleSet, error)); ok { + return returnFunc(ctx, runnerScaleSetId, runnerScaleSet) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int, *RunnerScaleSet) *RunnerScaleSet); ok { + r0 = returnFunc(ctx, runnerScaleSetId, runnerScaleSet) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSet) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int, *RunnerScaleSet) error); ok { + r1 = returnFunc(ctx, runnerScaleSetId, runnerScaleSet) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockActionsService_UpdateRunnerScaleSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRunnerScaleSet' +type MockActionsService_UpdateRunnerScaleSet_Call struct { + *mock.Call +} + +// UpdateRunnerScaleSet is a helper method to define mock.On call +// - ctx context.Context +// - runnerScaleSetId int +// - runnerScaleSet *RunnerScaleSet +func (_e *MockActionsService_Expecter) UpdateRunnerScaleSet(ctx interface{}, runnerScaleSetId interface{}, runnerScaleSet interface{}) *MockActionsService_UpdateRunnerScaleSet_Call { + return &MockActionsService_UpdateRunnerScaleSet_Call{Call: _e.mock.On("UpdateRunnerScaleSet", ctx, runnerScaleSetId, runnerScaleSet)} +} + +func (_c *MockActionsService_UpdateRunnerScaleSet_Call) Run(run func(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet)) *MockActionsService_UpdateRunnerScaleSet_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int + if args[1] != nil { + arg1 = args[1].(int) + } + var arg2 *RunnerScaleSet + if args[2] != nil { + arg2 = args[2].(*RunnerScaleSet) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockActionsService_UpdateRunnerScaleSet_Call) Return(runnerScaleSet1 *RunnerScaleSet, err error) *MockActionsService_UpdateRunnerScaleSet_Call { + _c.Call.Return(runnerScaleSet1, err) + return _c +} + +func (_c *MockActionsService_UpdateRunnerScaleSet_Call) RunAndReturn(run func(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)) *MockActionsService_UpdateRunnerScaleSet_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSessionService creates a new instance of MockSessionService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSessionService(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSessionService { + mock := &MockSessionService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} + +// MockSessionService is an autogenerated mock type for the SessionService type +type MockSessionService struct { + mock.Mock +} + +type MockSessionService_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSessionService) EXPECT() *MockSessionService_Expecter { + return &MockSessionService_Expecter{mock: &_m.Mock} +} + +// AcquireJobs provides a mock function for the type MockSessionService +func (_mock *MockSessionService) AcquireJobs(ctx context.Context, requestIds []int64) ([]int64, error) { + ret := _mock.Called(ctx, requestIds) + + if len(ret) == 0 { + panic("no return value specified for AcquireJobs") + } + + var r0 []int64 + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, []int64) ([]int64, error)); ok { + return returnFunc(ctx, requestIds) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, []int64) []int64); ok { + r0 = returnFunc(ctx, requestIds) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]int64) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, []int64) error); ok { + r1 = returnFunc(ctx, requestIds) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockSessionService_AcquireJobs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AcquireJobs' +type MockSessionService_AcquireJobs_Call struct { + *mock.Call +} + +// AcquireJobs is a helper method to define mock.On call +// - ctx context.Context +// - requestIds []int64 +func (_e *MockSessionService_Expecter) AcquireJobs(ctx interface{}, requestIds interface{}) *MockSessionService_AcquireJobs_Call { + return &MockSessionService_AcquireJobs_Call{Call: _e.mock.On("AcquireJobs", ctx, requestIds)} +} + +func (_c *MockSessionService_AcquireJobs_Call) Run(run func(ctx context.Context, requestIds []int64)) *MockSessionService_AcquireJobs_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 []int64 + if args[1] != nil { + arg1 = args[1].([]int64) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockSessionService_AcquireJobs_Call) Return(int64s []int64, err error) *MockSessionService_AcquireJobs_Call { + _c.Call.Return(int64s, err) + return _c +} + +func (_c *MockSessionService_AcquireJobs_Call) RunAndReturn(run func(ctx context.Context, requestIds []int64) ([]int64, error)) *MockSessionService_AcquireJobs_Call { + _c.Call.Return(run) + return _c +} + +// Close provides a mock function for the type MockSessionService +func (_mock *MockSessionService) Close() error { + ret := _mock.Called() + + if len(ret) == 0 { + panic("no return value specified for Close") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func() error); ok { + r0 = returnFunc() + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockSessionService_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close' +type MockSessionService_Close_Call struct { + *mock.Call +} + +// Close is a helper method to define mock.On call +func (_e *MockSessionService_Expecter) Close() *MockSessionService_Close_Call { + return &MockSessionService_Close_Call{Call: _e.mock.On("Close")} +} + +func (_c *MockSessionService_Close_Call) Run(run func()) *MockSessionService_Close_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockSessionService_Close_Call) Return(err error) *MockSessionService_Close_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockSessionService_Close_Call) RunAndReturn(run func() error) *MockSessionService_Close_Call { + _c.Call.Return(run) + return _c +} + +// DeleteMessage provides a mock function for the type MockSessionService +func (_mock *MockSessionService) DeleteMessage(ctx context.Context, messageId int64) error { + ret := _mock.Called(ctx, messageId) + + if len(ret) == 0 { + panic("no return value specified for DeleteMessage") + } + + var r0 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = returnFunc(ctx, messageId) + } else { + r0 = ret.Error(0) + } + return r0 +} + +// MockSessionService_DeleteMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteMessage' +type MockSessionService_DeleteMessage_Call struct { + *mock.Call +} + +// DeleteMessage is a helper method to define mock.On call +// - ctx context.Context +// - messageId int64 +func (_e *MockSessionService_Expecter) DeleteMessage(ctx interface{}, messageId interface{}) *MockSessionService_DeleteMessage_Call { + return &MockSessionService_DeleteMessage_Call{Call: _e.mock.On("DeleteMessage", ctx, messageId)} +} + +func (_c *MockSessionService_DeleteMessage_Call) Run(run func(ctx context.Context, messageId int64)) *MockSessionService_DeleteMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int64 + if args[1] != nil { + arg1 = args[1].(int64) + } + run( + arg0, + arg1, + ) + }) + return _c +} + +func (_c *MockSessionService_DeleteMessage_Call) Return(err error) *MockSessionService_DeleteMessage_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockSessionService_DeleteMessage_Call) RunAndReturn(run func(ctx context.Context, messageId int64) error) *MockSessionService_DeleteMessage_Call { + _c.Call.Return(run) + return _c +} + +// GetMessage provides a mock function for the type MockSessionService +func (_mock *MockSessionService) GetMessage(ctx context.Context, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error) { + ret := _mock.Called(ctx, lastMessageId, maxCapacity) + + if len(ret) == 0 { + panic("no return value specified for GetMessage") + } + + var r0 *RunnerScaleSetMessage + var r1 error + if returnFunc, ok := ret.Get(0).(func(context.Context, int64, int) (*RunnerScaleSetMessage, error)); ok { + return returnFunc(ctx, lastMessageId, maxCapacity) + } + if returnFunc, ok := ret.Get(0).(func(context.Context, int64, int) *RunnerScaleSetMessage); ok { + r0 = returnFunc(ctx, lastMessageId, maxCapacity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*RunnerScaleSetMessage) + } + } + if returnFunc, ok := ret.Get(1).(func(context.Context, int64, int) error); ok { + r1 = returnFunc(ctx, lastMessageId, maxCapacity) + } else { + r1 = ret.Error(1) + } + return r0, r1 +} + +// MockSessionService_GetMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMessage' +type MockSessionService_GetMessage_Call struct { + *mock.Call +} + +// GetMessage is a helper method to define mock.On call +// - ctx context.Context +// - lastMessageId int64 +// - maxCapacity int +func (_e *MockSessionService_Expecter) GetMessage(ctx interface{}, lastMessageId interface{}, maxCapacity interface{}) *MockSessionService_GetMessage_Call { + return &MockSessionService_GetMessage_Call{Call: _e.mock.On("GetMessage", ctx, lastMessageId, maxCapacity)} +} + +func (_c *MockSessionService_GetMessage_Call) Run(run func(ctx context.Context, lastMessageId int64, maxCapacity int)) *MockSessionService_GetMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + var arg0 context.Context + if args[0] != nil { + arg0 = args[0].(context.Context) + } + var arg1 int64 + if args[1] != nil { + arg1 = args[1].(int64) + } + var arg2 int + if args[2] != nil { + arg2 = args[2].(int) + } + run( + arg0, + arg1, + arg2, + ) + }) + return _c +} + +func (_c *MockSessionService_GetMessage_Call) Return(runnerScaleSetMessage *RunnerScaleSetMessage, err error) *MockSessionService_GetMessage_Call { + _c.Call.Return(runnerScaleSetMessage, err) + return _c +} + +func (_c *MockSessionService_GetMessage_Call) RunAndReturn(run func(ctx context.Context, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error)) *MockSessionService_GetMessage_Call { + _c.Call.Return(run) + return _c +} diff --git a/github/actions/sessionservice.go b/github/actions/sessionservice.go index 21311aa0..69389813 100644 --- a/github/actions/sessionservice.go +++ b/github/actions/sessionservice.go @@ -5,7 +5,7 @@ import ( "io" ) -//go:generate mockery --inpackage --name=SessionService +//go:generate mockery type SessionService interface { GetMessage(ctx context.Context, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error) DeleteMessage(ctx context.Context, messageId int64) error