Add unit test for describe-image
Add a unit test for testing that providing only the required command line arguments produces expected output. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
aecbe5928a
commit
1a2f4be378
1 changed files with 28 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ import (
|
||||||
main "github.com/osbuild/image-builder-cli/cmd/image-builder"
|
main "github.com/osbuild/image-builder-cli/cmd/image-builder"
|
||||||
"github.com/osbuild/image-builder-cli/internal/manifesttest"
|
"github.com/osbuild/image-builder-cli/internal/manifesttest"
|
||||||
"github.com/osbuild/image-builder-cli/internal/testutil"
|
"github.com/osbuild/image-builder-cli/internal/testutil"
|
||||||
|
"github.com/osbuild/images/pkg/arch"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -709,6 +710,33 @@ type: qcow2
|
||||||
arch: x86_64`)
|
arch: x86_64`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDescribeImageMinimal(t *testing.T) {
|
||||||
|
restore := main.MockNewRepoRegistry(testrepos.New)
|
||||||
|
defer restore()
|
||||||
|
|
||||||
|
restore = main.MockDistroGetHostDistroName(func() (string, error) {
|
||||||
|
return "centos-9", nil
|
||||||
|
})
|
||||||
|
defer restore()
|
||||||
|
|
||||||
|
restore = main.MockOsArgs([]string{
|
||||||
|
"describe",
|
||||||
|
"qcow2",
|
||||||
|
})
|
||||||
|
defer restore()
|
||||||
|
|
||||||
|
var fakeStdout bytes.Buffer
|
||||||
|
restore = main.MockOsStdout(&fakeStdout)
|
||||||
|
defer restore()
|
||||||
|
|
||||||
|
err := main.Run()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
assert.Contains(t, fakeStdout.String(), fmt.Sprintf(`distro: centos-9
|
||||||
|
type: qcow2
|
||||||
|
arch: %s`, arch.Current().String()))
|
||||||
|
}
|
||||||
|
|
||||||
func TestProgressFromCmd(t *testing.T) {
|
func TestProgressFromCmd(t *testing.T) {
|
||||||
cmd := &cobra.Command{}
|
cmd := &cobra.Command{}
|
||||||
cmd.Flags().String("progress", "auto", "")
|
cmd.Flags().String("progress", "auto", "")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue