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
+18 -18
View File
@@ -17,7 +17,7 @@ func TestConfigCmdBasics(t *testing.T) {
args := []string{"--help"}
configPath := makeConfigFile("showspinner = false")
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -29,7 +29,7 @@ func TestConfigCmdBasics(t *testing.T) {
args[0] = "-h"
configPath := makeConfigFile("showspinner = false")
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -44,7 +44,7 @@ func TestConfigCmdBasics(t *testing.T) {
args := []string{}
configPath := makeConfigFile("showspinner = false")
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -60,7 +60,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"add", "configtest1", "https://test-url.com"}
file := makeConfigFile("")
defer os.Remove(file)
cmd := NewConfigCommand(file)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -80,7 +80,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"add", "configtest1", "test..com"}
file := makeConfigFile("")
defer os.Remove(file)
cmd := NewConfigCommand(file)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -94,7 +94,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"--list"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -107,7 +107,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"-l"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -121,7 +121,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"-l"}
configPath := makeConfigFile(``)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -136,7 +136,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "--list"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -150,7 +150,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "-l"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -165,7 +165,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "-l"}
configPath := makeConfigFile(``)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -180,7 +180,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "url"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -193,7 +193,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "url"}
configPath := makeConfigFile(``)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(buff)
@@ -208,7 +208,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "showspinner", "false"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com"}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -229,7 +229,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "showspinner", "false"}
configPath := makeConfigFile(``)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -244,7 +244,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "url", "https://new-url.com"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -267,7 +267,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "showspinner", "--reset"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
@@ -289,7 +289,7 @@ func TestConfigCmdMain(t *testing.T) {
args := []string{"configtest", "url", "--reset"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)