mirror of
https://github.com/89luca89/distrobox.git
synced 2026-08-17 16:34:42 -05:00
test(commands): make generate-all-entries test hermetic
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
@@ -32,7 +32,6 @@ import (
|
|||||||
"github.com/89luca89/distrobox/pkg/commands"
|
"github.com/89luca89/distrobox/pkg/commands"
|
||||||
"github.com/89luca89/distrobox/pkg/config"
|
"github.com/89luca89/distrobox/pkg/config"
|
||||||
"github.com/89luca89/distrobox/pkg/containermanager"
|
"github.com/89luca89/distrobox/pkg/containermanager"
|
||||||
"github.com/89luca89/distrobox/pkg/containermanager/providers"
|
|
||||||
"github.com/89luca89/distrobox/pkg/internal/testutil"
|
"github.com/89luca89/distrobox/pkg/internal/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -174,9 +173,15 @@ func TestGenerateAllEntriesCommand_Execute(t *testing.T) {
|
|||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
defer os.RemoveAll(tempDir)
|
defer os.RemoveAll(tempDir)
|
||||||
|
|
||||||
// create the list command
|
// Mock manager keeps this deterministic and offline (a real docker made it
|
||||||
containerManager := providers.NewDocker(false, "sudo", false)
|
// fail with exit 127); the non-distro images resolve to the fallback icon.
|
||||||
listCmd := commands.NewListCommand(&config.Values{}, containerManager)
|
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
|
// create the generate all entries command
|
||||||
genAllEntriesCmd := commands.NewGenerateEntryCommand(&config.Values{}, listCmd)
|
genAllEntriesCmd := commands.NewGenerateEntryCommand(&config.Values{}, listCmd)
|
||||||
|
|||||||
Reference in New Issue
Block a user