Merge pull request #2 from actions/nikola-jokic/remove-interface-and-mocks

Remove interfaces, mocks, and unused identity_test
This commit is contained in:
Francesco Renzi
2025-10-30 10:42:13 +00:00
committed by GitHub
5 changed files with 2 additions and 741 deletions
+2 -33
View File
@@ -26,42 +26,13 @@ import (
)
const (
runnerEndpoint = "_apis/distributedtask/pools/0/agents"
scaleSetEndpoint = "_apis/runtime/runnerscalesets"
apiVersionQueryParam = "api-version=6.0-preview"
runnerEndpoint = "_apis/distributedtask/pools/0/agents"
scaleSetEndpoint = "_apis/runtime/runnerscalesets"
)
// Header used to propagate capacity information to the back-end
const HeaderScaleSetMaxCapacity = "X-ScaleSetMaxCapacity"
//go:generate mockery --inpackage --name=ActionsService
type ActionsService interface {
GetRunnerScaleSet(ctx context.Context, runnerGroupId int, runnerScaleSetName string) (*RunnerScaleSet, error)
GetRunnerScaleSetById(ctx context.Context, runnerScaleSetId int) (*RunnerScaleSet, error)
GetRunnerGroupByName(ctx context.Context, runnerGroup string) (*RunnerGroup, error)
CreateRunnerScaleSet(ctx context.Context, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
UpdateRunnerScaleSet(ctx context.Context, runnerScaleSetId int, runnerScaleSet *RunnerScaleSet) (*RunnerScaleSet, error)
DeleteRunnerScaleSet(ctx context.Context, runnerScaleSetId int) error
CreateMessageSession(ctx context.Context, runnerScaleSetId int, owner string) (*RunnerScaleSetSession, error)
DeleteMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) error
RefreshMessageSession(ctx context.Context, runnerScaleSetId int, sessionId *uuid.UUID) (*RunnerScaleSetSession, error)
AcquireJobs(ctx context.Context, runnerScaleSetId int, messageQueueAccessToken string, requestIds []int64) ([]int64, error)
GetAcquirableJobs(ctx context.Context, runnerScaleSetId int) (*AcquirableJobList, error)
GetMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error)
DeleteMessage(ctx context.Context, messageQueueUrl, messageQueueAccessToken string, messageId int64) error
GenerateJitRunnerConfig(ctx context.Context, jitRunnerSetting *RunnerScaleSetJitRunnerSetting, scaleSetId int) (*RunnerScaleSetJitRunnerConfig, error)
GetRunner(ctx context.Context, runnerId int64) (*RunnerReference, error)
GetRunnerByName(ctx context.Context, runnerName string) (*RunnerReference, error)
RemoveRunner(ctx context.Context, runnerId int64) error
SetUserAgent(info UserAgentInfo)
}
type Client struct {
*http.Client
@@ -102,8 +73,6 @@ type ActionsAuth struct {
Token string
}
var _ ActionsService = &Client{}
type ProxyFunc func(req *http.Request) (*url.URL, error)
type ClientOption func(*Client)
-158
View File
@@ -1,158 +0,0 @@
package scaleset_test
import (
"crypto/x509"
"os"
"path/filepath"
"testing"
"github.com/actions/scaleset"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestClient_Identifier(t *testing.T) {
t.Run("configURL changes", func(t *testing.T) {
scenarios := []struct {
name string
url string
}{
{
name: "url of a different repo",
url: "https://github.com/org/repo2",
},
{
name: "url of an org",
url: "https://github.com/org",
},
{
name: "url of an enterprise",
url: "https://github.com/enterprises/my-enterprise",
},
{
name: "url of a self-hosted github",
url: "https://selfhosted.com/org/repo",
},
}
configURL := "https://github.com/org/repo"
defaultCreds := &scaleset.ActionsAuth{
Token: "token",
}
oldClient, err := scaleset.NewClient(configURL, defaultCreds)
require.NoError(t, err)
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
newClient, err := scaleset.NewClient(scenario.url, defaultCreds)
require.NoError(t, err)
assert.NotEqual(t, oldClient.Identifier(), newClient.Identifier())
})
}
})
t.Run("credentials change", func(t *testing.T) {
defaultTokenCreds := &scaleset.ActionsAuth{
Token: "token",
}
defaultAppCreds := &scaleset.ActionsAuth{
AppCreds: &scaleset.GitHubAppAuth{
AppID: "123",
AppInstallationID: 123,
AppPrivateKey: "private key",
},
}
scenarios := []struct {
name string
old *scaleset.ActionsAuth
new *scaleset.ActionsAuth
}{
{
name: "different token",
old: defaultTokenCreds,
new: &scaleset.ActionsAuth{
Token: "new token",
},
},
{
name: "changing from token to github app",
old: defaultTokenCreds,
new: defaultAppCreds,
},
{
name: "changing from github app to token",
old: defaultAppCreds,
new: defaultTokenCreds,
},
{
name: "different github app",
old: defaultAppCreds,
new: &scaleset.ActionsAuth{
AppCreds: &scaleset.GitHubAppAuth{
AppID: "456",
AppInstallationID: 456,
AppPrivateKey: "new private key",
},
},
},
}
defaultConfigURL := "https://github.com/org/repo"
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
oldClient, err := scaleset.NewClient(defaultConfigURL, scenario.old)
require.NoError(t, err)
newClient, err := scaleset.NewClient(defaultConfigURL, scenario.new)
require.NoError(t, err)
assert.NotEqual(t, oldClient.Identifier(), newClient.Identifier())
})
}
})
t.Run("changes in TLS config", func(t *testing.T) {
configURL := "https://github.com/org/repo"
defaultCreds := &scaleset.ActionsAuth{
Token: "token",
}
noTlS, err := scaleset.NewClient(configURL, defaultCreds)
require.NoError(t, err)
poolFromCert := func(t *testing.T, path string) *x509.CertPool {
t.Helper()
f, err := os.ReadFile(path)
require.NoError(t, err)
pool := x509.NewCertPool()
require.True(t, pool.AppendCertsFromPEM(f))
return pool
}
root, err := scaleset.NewClient(
configURL,
defaultCreds,
scaleset.WithRootCAs(poolFromCert(t, filepath.Join("testdata", "rootCA.crt"))),
)
require.NoError(t, err)
chain, err := scaleset.NewClient(
configURL,
defaultCreds,
scaleset.WithRootCAs(poolFromCert(t, filepath.Join("testdata", "intermediate.crt"))),
)
require.NoError(t, err)
clients := []*scaleset.Client{
noTlS,
root,
chain,
}
identifiers := map[string]struct{}{}
for _, client := range clients {
identifiers[client.Identifier()] = struct{}{}
}
assert.Len(t, identifiers, len(clients), "all clients should have a unique identifier")
})
}
-428
View File
@@ -1,428 +0,0 @@
// Code generated by mockery v2.36.1. DO NOT EDIT.
package scaleset
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
}
-108
View File
@@ -1,108 +0,0 @@
// Code generated by mockery v2.36.1. DO NOT EDIT.
package scaleset
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
}
-14
View File
@@ -1,14 +0,0 @@
package scaleset
import (
"context"
"io"
)
//go:generate mockery --inpackage --name=SessionService
type SessionService interface {
GetMessage(ctx context.Context, lastMessageId int64, maxCapacity int) (*RunnerScaleSetMessage, error)
DeleteMessage(ctx context.Context, messageId int64) error
AcquireJobs(ctx context.Context, requestIds []int64) ([]int64, error)
io.Closer
}