cli: move client-only code out of the server flow

earlier, some of the client exclusive code was being run on zot server
instance too.

cli: fix the bug: spinner is not stopped with -o
This commit is contained in:
Tanmay Naik
2020-07-14 13:11:01 -04:00
parent e639b4814e
commit bb9fbd2ef9
9 changed files with 86 additions and 73 deletions
+7 -7
View File
@@ -17,13 +17,13 @@ func TestUsage(t *testing.T) {
Convey("Test usage", t, func(c C) {
os.Args = []string{"cli_test", "help"}
err := cli.NewRootCmd(os.TempDir()).Execute()
err := cli.NewRootCmd().Execute()
So(err, ShouldBeNil)
})
Convey("Test version", t, func(c C) {
os.Args = []string{"cli_test", "--version"}
err := cli.NewRootCmd(os.TempDir()).Execute()
err := cli.NewRootCmd().Execute()
So(err, ShouldBeNil)
})
}
@@ -35,19 +35,19 @@ func TestServe(t *testing.T) {
Convey("Test serve help", t, func(c C) {
os.Args = []string{"cli_test", "serve", "-h"}
err := cli.NewRootCmd(os.TempDir()).Execute()
err := cli.NewRootCmd().Execute()
So(err, ShouldBeNil)
})
Convey("Test serve config", t, func(c C) {
Convey("unknown config", func(c C) {
os.Args = []string{"cli_test", "serve", path.Join(os.TempDir(), "/x")}
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
})
Convey("non-existent config", func(c C) {
os.Args = []string{"cli_test", "serve", path.Join(os.TempDir(), "/x.yaml")}
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
})
Convey("bad config", func(c C) {
@@ -60,7 +60,7 @@ func TestServe(t *testing.T) {
err = tmpfile.Close()
So(err, ShouldBeNil)
os.Args = []string{"cli_test", "serve", tmpfile.Name()}
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
})
})
}
@@ -72,7 +72,7 @@ func TestGC(t *testing.T) {
Convey("Test gc", t, func(c C) {
os.Args = []string{"cli_test", "garbage-collect", "-h"}
err := cli.NewRootCmd(os.TempDir()).Execute()
err := cli.NewRootCmd().Execute()
So(err, ShouldBeNil)
})
}