Skip to content

Commit

Permalink
Pass port to service model
Browse files Browse the repository at this point in the history
  • Loading branch information
MDrakos committed Oct 2, 2024
1 parent 99fbb8f commit b7cd507
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/scriptrun/test/integration/scriptrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import (
"testing"

"github.com/ActiveState/cli/internal/analytics/client/blackhole"
"github.com/ActiveState/cli/internal/installation"
"github.com/ActiveState/cli/internal/primer"
"github.com/ActiveState/cli/internal/scriptrun"
"github.com/ActiveState/cli/internal/svcctl"
"github.com/ActiveState/cli/internal/testhelpers/e2e"
"github.com/ActiveState/cli/internal/testhelpers/suite"
"github.com/ActiveState/cli/internal/testhelpers/tagsuite"
"github.com/kami-zh/go-capturer"
Expand Down Expand Up @@ -87,6 +90,8 @@ scripts:
func (suite *ScriptRunSuite) TestEnvIsSet() {
suite.OnlyRunForTags(tagsuite.Scripts)
t := suite.T()
ts := e2e.New(suite.T(), false)
defer ts.Close()

if runtime.GOOS == "windows" {
// For some reason this test hangs on Windows when ran via CI. I cannot reproduce the issue when manually invoking the
Expand Down Expand Up @@ -119,8 +124,17 @@ func (suite *ScriptRunSuite) TestEnvIsSet() {

cfg.Set(constants.AsyncRuntimeConfig, true)

ipcClient := svcctl.NewDefaultIPCClient()
var svcPort string

svcExec, err := installation.ServiceExecFromDir(ts.Dirs.Bin)
suite.Require().NoError(err, errs.JoinMessage(err))

svcPort, err = svcctl.EnsureExecStartedAndLocateHTTP(ipcClient, svcExec, "from test", nil)
suite.Require().NoError(err, errs.JoinMessage(err))

out := capturer.CaptureOutput(func() {
scriptRun := scriptrun.New(primer.New(auth, outputhelper.NewCatcher(), subshell.New(cfg), proj, cfg, blackhole.New(), model.NewSvcModel("")))
scriptRun := scriptrun.New(primer.New(auth, outputhelper.NewCatcher(), subshell.New(cfg), proj, cfg, blackhole.New(), model.NewSvcModel(svcPort)))
script, err := proj.ScriptByName("run")
require.NoError(t, err, "Error: "+errs.JoinMessage(err))
err = scriptRun.Run(script, nil)
Expand Down

0 comments on commit b7cd507

Please sign in to comment.