test(commands): make generate-all-entries test hermetic

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio
2026-07-25 11:56:17 +02:00
parent e15c09fe97
commit 24eeae0f86
+9 -4
View File
@@ -32,7 +32,6 @@ import (
"github.com/89luca89/distrobox/pkg/commands"
"github.com/89luca89/distrobox/pkg/config"
"github.com/89luca89/distrobox/pkg/containermanager"
"github.com/89luca89/distrobox/pkg/containermanager/providers"
"github.com/89luca89/distrobox/pkg/internal/testutil"
)
@@ -174,9 +173,15 @@ func TestGenerateAllEntriesCommand_Execute(t *testing.T) {
tempDir := t.TempDir()
defer os.RemoveAll(tempDir)
// create the list command
containerManager := providers.NewDocker(false, "sudo", false)
listCmd := commands.NewListCommand(&config.Values{}, containerManager)
// Mock manager keeps this deterministic and offline (a real docker made it
// fail with exit 127); the non-distro images resolve to the fallback icon.
mock := &testutil.MockContainerManager{
ListContainersResult: []containermanager.Container{
{Name: "boxone", Image: "example.com/appone:1", Status: "Exited", Labels: map[string]string{"manager": "distrobox"}},
{Name: "boxtwo", Image: "example.com/apptwo:1", Status: "Exited", Labels: map[string]string{"manager": "distrobox"}},
},
}
listCmd := commands.NewListCommand(&config.Values{}, mock)
// create the generate all entries command
genAllEntriesCmd := commands.NewGenerateEntryCommand(&config.Values{}, listCmd)