Raise error when adding a new zot config with an existed saved name

This commit is contained in:
Ionut Costin Craciun
2020-10-29 14:47:27 +02:00
parent 429a689ace
commit dad884ddeb
3 changed files with 30 additions and 0 deletions
+14
View File
@@ -300,4 +300,18 @@ func TestConfigCmdMain(t *testing.T) {
So(err, ShouldNotBeNil)
So(buff.String(), ShouldContainSubstring, "cannot reset")
})
Convey("Test add a config with an existing saved name", t, func() {
args := []string{"add", "configtest", "https://test-url.com/new"}
configPath := makeConfigFile(`{"configs":[{"_name":"configtest","url":"https://test-url.com","showspinner":false}]}`)
defer os.Remove(configPath)
cmd := NewConfigCommand()
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(ioutil.Discard)
cmd.SetArgs(args)
err := cmd.Execute()
So(err, ShouldNotBeNil)
So(buff.String(), ShouldContainSubstring, "cli config name already added")
})
}