Fix tests and nit

Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
This commit is contained in:
Nassim 'Nass' Eddequiouaq 2018-06-05 22:17:32 -07:00
parent 448082f333
commit 5ebb7a65ab
2 changed files with 6 additions and 5 deletions

View File

@ -46,10 +46,8 @@ func removeSigner(cli command.Cli, options signerRemoveOptions) error {
if didRemove, err := removeSingleSigner(cli, repo, options.signer, options.forceYes); err != nil { if didRemove, err := removeSingleSigner(cli, repo, options.signer, options.forceYes); err != nil {
fmt.Fprintln(cli.Err(), err.Error()+"\n") fmt.Fprintln(cli.Err(), err.Error()+"\n")
errRepos = append(errRepos, repo) errRepos = append(errRepos, repo)
} else { } else if didRemove {
if didRemove { fmt.Fprintf(cli.Out(), "Successfully removed %s from %s\n\n", options.signer, repo)
fmt.Fprintf(cli.Out(), "Successfully removed %s from %s\n\n", options.signer, repo)
}
} }
} }
if len(errRepos) > 0 { if len(errRepos) > 0 {

View File

@ -71,10 +71,13 @@ func TestTrustSignerRemoveErrors(t *testing.T) {
func TestRemoveSingleSigner(t *testing.T) { func TestRemoveSingleSigner(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{}) cli := test.NewFakeCli(&fakeClient{})
cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository) cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository)
_, err := removeSingleSigner(cli, "signed-repo", "test", true) didRemove, err := removeSingleSigner(cli, "signed-repo", "test", true)
assert.Error(t, err, "No signer test for repository signed-repo") assert.Error(t, err, "No signer test for repository signed-repo")
assert.Equal(t, didRemove, false, "No signer should be removed")
_, err = removeSingleSigner(cli, "signed-repo", "releases", true) _, err = removeSingleSigner(cli, "signed-repo", "releases", true)
assert.Error(t, err, "releases is a reserved keyword and cannot be removed") assert.Error(t, err, "releases is a reserved keyword and cannot be removed")
assert.Equal(t, didRemove, false, "No signer should be removed")
} }
func TestRemoveMultipleSigners(t *testing.T) { func TestRemoveMultipleSigners(t *testing.T) {