mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 20:07:55 +08:00
fix(cli/server): serve command expected positional args (#2382)
fix(cli/server): serve command expected positinal args Expect exactly one positional argument for the serve command with the path to the config file. Signed-off-by: Ramiro Algozino <ramiro@sighup.io>
This commit is contained in:
@@ -47,6 +47,7 @@ func newServeCmd(conf *config.Config) *cobra.Command {
|
||||
Aliases: []string{"serve"},
|
||||
Short: "`serve` stores and distributes OCI images",
|
||||
Long: "`serve` stores and distributes OCI images",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) > 0 {
|
||||
if err := LoadConfiguration(conf, args[0]); err != nil {
|
||||
|
||||
@@ -48,6 +48,18 @@ func TestServe(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Test serve config", t, func(c C) {
|
||||
Convey("no config arg", func(c C) {
|
||||
os.Args = []string{"cli_test", "serve"}
|
||||
err := cli.NewServerRootCmd().Execute()
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("two args", func(c C) {
|
||||
os.Args = []string{"cli_test", "serve", "config", "second arg"}
|
||||
err := cli.NewServerRootCmd().Execute()
|
||||
So(err, ShouldNotBeNil)
|
||||
})
|
||||
|
||||
Convey("unknown config", func(c C) {
|
||||
os.Args = []string{"cli_test", "serve", path.Join(os.TempDir(), "/x")}
|
||||
err := cli.NewServerRootCmd().Execute()
|
||||
|
||||
Reference in New Issue
Block a user