diff --git a/internal/processmanager/simple.go b/internal/processmanager/simple.go index 420bfa1..6d6d3e1 100644 --- a/internal/processmanager/simple.go +++ b/internal/processmanager/simple.go @@ -91,16 +91,11 @@ func (pm *Simple) SendInput( func (pm *Simple) execCommand( ctx context.Context, server *domain.Server, command string, out io.Writer, ) (domain.Result, error) { - options, err := pm.executeOptions(server) - if err != nil { - return domain.ErrorResult, errors.WithMessage(err, "invalid server configuration") - } - result, err := pm.executor.ExecWithWriter( ctx, command, out, - options, + pm.executeOptions(server), ) if err != nil { return domain.ErrorResult, errors.WithMessage(err, "failed to exec command") @@ -109,9 +104,9 @@ func (pm *Simple) execCommand( return domain.Result(result), nil } -func (pm *Simple) executeOptions(server *domain.Server) (contracts.ExecutorOptions, error) { +func (pm *Simple) executeOptions(server *domain.Server) contracts.ExecutorOptions { return contracts.ExecutorOptions{ WorkDir: server.WorkDir(pm.cfg), FallbackWorkDir: pm.cfg.WorkDir(), - }, nil + } } diff --git a/test/functional/gdtasks/suite.go b/test/functional/gdtasks/suite.go index 29418ce..ca473f8 100644 --- a/test/functional/gdtasks/suite.go +++ b/test/functional/gdtasks/suite.go @@ -15,6 +15,7 @@ import ( gameservercommands "github.com/gameap/daemon/internal/app/game_server_commands" gdaemonscheduler "github.com/gameap/daemon/internal/app/gdaemon_scheduler" "github.com/gameap/daemon/internal/app/services" + "github.com/gameap/daemon/internal/processmanager" "github.com/gameap/daemon/test/functional" "github.com/gameap/daemon/test/mocks" ) @@ -28,6 +29,7 @@ type Suite struct { GDTaskRepository *mocks.GDTaskRepository ServerRepository *mocks.ServerRepository Executor contracts.Executor + ProcessManager contracts.ProcessManager Cache contracts.Cache Cfg *config.Config @@ -42,6 +44,7 @@ func (suite *Suite) SetupTest() { suite.Cfg, suite.ServerRepository, suite.Executor, + suite.ProcessManager, ), suite.Executor, suite.Cfg, @@ -62,6 +65,7 @@ func (suite *Suite) SetupSuite() { } suite.Executor = components.NewDefaultExtendableExecutor(suite.Cfg) + suite.ProcessManager = processmanager.NewSimple(suite.Cfg, suite.Executor) suite.Cache, err = services.NewLocalCache(suite.Cfg) if err != nil { diff --git a/test/functional/server_tasks/suite_test.go b/test/functional/server_tasks/suite_test.go index ee28533..f17e7f4 100644 --- a/test/functional/server_tasks/suite_test.go +++ b/test/functional/server_tasks/suite_test.go @@ -12,6 +12,7 @@ import ( "github.com/gameap/daemon/internal/app/domain" gameservercommands "github.com/gameap/daemon/internal/app/game_server_commands" serversscheduler "github.com/gameap/daemon/internal/app/servers_scheduler" + "github.com/gameap/daemon/internal/processmanager" "github.com/gameap/daemon/test/functional" "github.com/gameap/daemon/test/mocks" "github.com/otiai10/copy" @@ -25,6 +26,7 @@ type Suite struct { ServerTaskRepository *mocks.ServerTaskRepository ServerRepository *mocks.ServerRepository Executor contracts.Executor + ProcessManager contracts.ProcessManager Cfg *config.Config WorkPath string @@ -35,16 +37,17 @@ func TestSuite(t *testing.T) { } func (suite *Suite) SetupSuite() { - suite.ServerRepository = mocks.NewServerRepository() - suite.ServerTaskRepository = mocks.NewServerTaskRepository() - suite.Executor = components.NewExecutor() - suite.Cfg = &config.Config{ Scripts: config.Scripts{ Start: "{command}", Stop: "{command}", }, } + + suite.ServerRepository = mocks.NewServerRepository() + suite.ServerTaskRepository = mocks.NewServerTaskRepository() + suite.Executor = components.NewExecutor() + suite.ProcessManager = processmanager.NewSimple(suite.Cfg, suite.Executor) } func (suite *Suite) SetupTest() { @@ -60,6 +63,7 @@ func (suite *Suite) SetupTest() { suite.Cfg, suite.ServerRepository, suite.Executor, + suite.ProcessManager, ), ) diff --git a/test/functional/serverscommand/notinstalled_server_suite.go b/test/functional/serverscommand/notinstalled_server_suite.go index 6c27f62..82c7632 100644 --- a/test/functional/serverscommand/notinstalled_server_suite.go +++ b/test/functional/serverscommand/notinstalled_server_suite.go @@ -8,6 +8,7 @@ import ( "github.com/gameap/daemon/internal/app/contracts" "github.com/gameap/daemon/internal/app/domain" gameservercommands "github.com/gameap/daemon/internal/app/game_server_commands" + "github.com/gameap/daemon/internal/processmanager" "github.com/gameap/daemon/test/functional" "github.com/gameap/daemon/test/mocks" ) @@ -19,6 +20,7 @@ type NotInstalledServerSuite struct { Cfg *config.Config ServerRepository domain.ServerRepository Executor contracts.Executor + ProcessManager contracts.ProcessManager WorkPath string } @@ -32,8 +34,9 @@ func (suite *NotInstalledServerSuite) SetupSuite() { suite.ServerRepository = mocks.NewServerRepository() suite.Executor = components.NewCleanExecutor() + suite.ProcessManager = processmanager.NewSimple(suite.Cfg, suite.Executor) - suite.CommandFactory = gameservercommands.NewFactory(suite.Cfg, suite.ServerRepository, suite.Executor) + suite.CommandFactory = gameservercommands.NewFactory(suite.Cfg, suite.ServerRepository, suite.Executor, suite.ProcessManager) } func (suite *NotInstalledServerSuite) SetupTest() {