Skip to content

Commit

Permalink
add test to reproduce bug
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwareus committed Oct 16, 2023
1 parent 04962ba commit d27de19
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/resolution/pm/pip/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,33 @@ func TestRunCleanErr(t *testing.T) {
assert.Len(t, j.Errors().GetAll(), 1)
assert.Contains(t, j.Errors().GetAll(), CleanErr)
}

var wasCalled bool

type pipCleanerMockCalled struct {
WasCalled bool
}

func (p pipCleanerMockCalled) RemoveAll(_ string) error {
wasCalled = true

return nil
}

func TestErrorStillClean(t *testing.T) {
cmdErr := errors.New("cmd-error")
cmdFactoryMock := testdata.NewEchoCmdFactory()
cmdFactoryMock.MakeInstallErr = cmdErr
fileWriterMock := &writerTestdata.FileWriterMock{}

wasCalled = false
cleaner := pipCleanerMockCalled{}
j := NewJob("file", true, cmdFactoryMock, fileWriterMock, cleaner)

go jobTestdata.WaitStatus(j)
j.Run()

assert.Len(t, j.Errors().GetAll(), 1)
assert.Contains(t, j.Errors().GetAll(), cmdErr)
assert.True(t, wasCalled)
}

0 comments on commit d27de19

Please sign in to comment.