add step list for server creation
All checks were successful
Release and Deploy / build (push) Successful in 9m5s
Release and Deploy / deploy (push) Successful in 26s

This commit is contained in:
Fran Jurmanović
2025-09-18 22:24:51 +02:00
parent 901dbe697e
commit 4004d83411
80 changed files with 950 additions and 2554 deletions

View File

@@ -8,7 +8,6 @@ import (
"github.com/google/uuid"
)
// MockConfigRepository provides a mock implementation of ConfigRepository
type MockConfigRepository struct {
configs map[string]*model.Config
shouldFailGet bool
@@ -21,7 +20,6 @@ func NewMockConfigRepository() *MockConfigRepository {
}
}
// UpdateConfig mocks the UpdateConfig method
func (m *MockConfigRepository) UpdateConfig(ctx context.Context, config *model.Config) *model.Config {
if m.shouldFailUpdate {
return nil
@@ -36,18 +34,15 @@ func (m *MockConfigRepository) UpdateConfig(ctx context.Context, config *model.C
return config
}
// SetShouldFailUpdate configures the mock to fail on UpdateConfig calls
func (m *MockConfigRepository) SetShouldFailUpdate(shouldFail bool) {
m.shouldFailUpdate = shouldFail
}
// GetConfig retrieves a config by server ID and config file
func (m *MockConfigRepository) GetConfig(serverID uuid.UUID, configFile string) *model.Config {
key := serverID.String() + "_" + configFile
return m.configs[key]
}
// MockServerRepository provides a mock implementation of ServerRepository
type MockServerRepository struct {
servers map[uuid.UUID]*model.Server
shouldFailGet bool
@@ -59,7 +54,6 @@ func NewMockServerRepository() *MockServerRepository {
}
}
// GetByID mocks the GetByID method
func (m *MockServerRepository) GetByID(ctx context.Context, id interface{}) (*model.Server, error) {
if m.shouldFailGet {
return nil, errors.New("server not found")
@@ -88,17 +82,14 @@ func (m *MockServerRepository) GetByID(ctx context.Context, id interface{}) (*mo
return server, nil
}
// AddServer adds a server to the mock repository
func (m *MockServerRepository) AddServer(server *model.Server) {
m.servers[server.ID] = server
}
// SetShouldFailGet configures the mock to fail on GetByID calls
func (m *MockServerRepository) SetShouldFailGet(shouldFail bool) {
m.shouldFailGet = shouldFail
}
// MockServerService provides a mock implementation of ServerService
type MockServerService struct {
startRuntimeCalled bool
startRuntimeServer *model.Server
@@ -108,23 +99,19 @@ func NewMockServerService() *MockServerService {
return &MockServerService{}
}
// StartAccServerRuntime mocks the StartAccServerRuntime method
func (m *MockServerService) StartAccServerRuntime(server *model.Server) {
m.startRuntimeCalled = true
m.startRuntimeServer = server
}
// WasStartRuntimeCalled returns whether StartAccServerRuntime was called
func (m *MockServerService) WasStartRuntimeCalled() bool {
return m.startRuntimeCalled
}
// GetStartRuntimeServer returns the server passed to StartAccServerRuntime
func (m *MockServerService) GetStartRuntimeServer() *model.Server {
return m.startRuntimeServer
}
// Reset resets the mock state
func (m *MockServerService) Reset() {
m.startRuntimeCalled = false
m.startRuntimeServer = nil