Skip to content

Commit 9a7c4df

Browse files
leodidoona-agent
andcommitted
fix: enable mock for unit tests that use dummy docker
Unit tests that use dummy docker (not real Docker) need the mock enabled because dummy docker doesn't create real images or OCI tars. Without the mock, container extraction fails with 'No such image' error when the test package has no image: config (which triggers extraction). Tests fixed: - TestBuildDockerDeps - TestDockerPostProcessing This resolves the CI unit test failures while keeping integration tests using real extraction code. Co-authored-by: Ona <[email protected]>
1 parent 2ef105b commit 9a7c4df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/leeway/build_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ func setupMockForUnitTests() func() {
118118
}
119119

120120
func TestBuildDockerDeps(t *testing.T) {
121+
// Enable mock for this test since it uses dummy docker (not real Docker)
122+
// Without the mock, container extraction would fail because dummy docker
123+
// doesn't create real images or OCI tars
124+
restoreMock := setupMockForUnitTests()
125+
defer restoreMock()
126+
121127
if *testutil.Dut {
122128
pth, err := os.MkdirTemp("", "")
123129
if err != nil {
@@ -548,6 +554,12 @@ func TestDockerPackage_BuildContextOverride(t *testing.T) {
548554
}
549555

550556
func TestDockerPostProcessing(t *testing.T) {
557+
// Enable mock for this test since it uses dummy docker (not real Docker)
558+
// Without the mock, container extraction would fail because dummy docker
559+
// doesn't create real images or OCI tars
560+
restoreMock := setupMockForUnitTests()
561+
defer restoreMock()
562+
551563
if *testutil.Dut {
552564
pth, err := os.MkdirTemp("", "")
553565
if err != nil {

0 commit comments

Comments
 (0)