diff --git a/internal/resolution/pm/nuget/job_test.go b/internal/resolution/pm/nuget/job_test.go index c7b795b2..3ea4c409 100644 --- a/internal/resolution/pm/nuget/job_test.go +++ b/internal/resolution/pm/nuget/job_test.go @@ -62,22 +62,3 @@ func TestRunInstallCmdOutputErr(t *testing.T) { jobTestdata.AssertPathErr(t, j.Errors()) } - -func TestRunInstallCmdOutputAndErr(t *testing.T) { - // Setup mock to return a specific error and output - expectedError := errors.New("expected error") - expectedOutput := []byte("expected output") - - cmdFactoryMock := testdata.NewEchoCmdFactory() - cmdFactoryMock.CmdOutput = expectedOutput - cmdFactoryMock.CmdError = expectedError - - j := NewJob("file", true, cmdFactoryMock) - - go jobTestdata.WaitStatus(j) - j.Run() - - // Check that the error recorded in j.Errors() matches the error created from the output - assert.Len(t, j.Errors().GetAll(), 1) - assert.Contains(t, j.Errors().GetAll(), errors.New(string(expectedOutput))) -} diff --git a/internal/resolution/pm/nuget/testdata/cmd_factory_mock.go b/internal/resolution/pm/nuget/testdata/cmd_factory_mock.go index 7c10977d..093ba6b2 100644 --- a/internal/resolution/pm/nuget/testdata/cmd_factory_mock.go +++ b/internal/resolution/pm/nuget/testdata/cmd_factory_mock.go @@ -7,8 +7,6 @@ import ( type CmdFactoryMock struct { InstallCmdName string MakeInstallErr error - CmdOutput []byte - CmdError error } func NewEchoCmdFactory() CmdFactoryMock { @@ -16,19 +14,7 @@ func NewEchoCmdFactory() CmdFactoryMock { InstallCmdName: "echo", } } -func (f CmdFactoryMock) MakeInstallCmd(command string, file string) (*exec.Cmd, error) { - if f.MakeInstallErr != nil { - return nil, f.MakeInstallErr - } - - cmd := exec.Command(f.InstallCmdName) - if f.CmdError != nil { - cmd = exec.Command("/bin/bash", "-c", f.InstallCmdName+" && exit 1") - } - if f.CmdOutput != nil { - cmd = exec.Command("/bin/bash", "-c", "echo -n \""+string(f.CmdOutput)+"\" && exit 1") - } - - return cmd, nil +func (f CmdFactoryMock) MakeInstallCmd(command string, file string) (*exec.Cmd, error) { + return exec.Command(f.InstallCmdName), f.MakeInstallErr }