mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-12 14:37:08 +08:00
cli: error out on unknown command
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
29
tests/common.go
Normal file
29
tests/common.go
Normal file
@ -0,0 +1,29 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/moby/buildkit/util/testutil/integration"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var commonTests = []func(t *testing.T, sb integration.Sandbox){
|
||||
testUnknownCommand,
|
||||
testUnknownFlag,
|
||||
}
|
||||
|
||||
func testUnknownCommand(t *testing.T, sb integration.Sandbox) {
|
||||
cmd := buildxCmd(sb, withArgs("foo"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.Error(t, err, string(out))
|
||||
|
||||
cmd = buildxCmd(sb, withArgs("imagetools", "foo"))
|
||||
out, err = cmd.CombinedOutput()
|
||||
require.Error(t, err, string(out))
|
||||
}
|
||||
|
||||
func testUnknownFlag(t *testing.T, sb integration.Sandbox) {
|
||||
cmd := buildxCmd(sb, withArgs("build", "--foo=bar"))
|
||||
out, err := cmd.CombinedOutput()
|
||||
require.Error(t, err, string(out))
|
||||
}
|
Reference in New Issue
Block a user