list-images: add --datadir override for e.g. custom repositories

This commit adds a `--datadir` override that allows overriding
the default search paths for e.g. the custom repositories. In
practise only repository overrides are supported because that
is the only data stored there.
This commit is contained in:
Michael Vogt 2024-11-27 09:04:59 +01:00
parent 56f9c6969c
commit 2719f3f727
6 changed files with 54 additions and 14 deletions

View file

@ -96,3 +96,15 @@ func TestBadCmdErrorsNoExtraCobraNoise(t *testing.T) {
// no extra output from cobra
assert.Equal(t, "", fakeStderr.String())
}
func TestListImagesOverrideDatadir(t *testing.T) {
restore := main.MockOsArgs([]string{"--datadir=/this/path/does/not/exist", "list-images"})
defer restore()
var fakeStdout bytes.Buffer
restore = main.MockOsStdout(&fakeStdout)
defer restore()
err := main.Run()
assert.EqualError(t, err, `no repositories found in the given paths: [/this/path/does/not/exist]`)
}