Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Review corrections
Browse files Browse the repository at this point in the history
Signed-off-by: Henrique Moraes <henrique.moraes@zup.com.br>
  • Loading branch information
henriquemoraeszup committed Dec 19, 2020
1 parent d87b133 commit ccbf9f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 3 additions & 4 deletions pkg/cmd/delete_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ func (d deleteCredentialCmd) runFormula() CommandRunnerFunc {
inputParams, err := d.resolveInput(cmd, curEnv)
if err != nil {
return err
} else if inputParams.provider == "" {
return nil
}

if err := d.Delete(inputParams.provider); err != nil {
Expand All @@ -93,9 +91,8 @@ func (d deleteCredentialCmd) runFormula() CommandRunnerFunc {
func (d *deleteCredentialCmd) resolveInput(cmd *cobra.Command, context string) (inputConfig, error) {
if IsFlagInput(cmd) {
return d.resolveFlags(cmd)
} else {
return d.resolvePrompt(context)
}
return d.resolvePrompt(context)
}

func (d *deleteCredentialCmd) resolvePrompt(context string) (inputConfig, error) {
Expand Down Expand Up @@ -130,6 +127,8 @@ func (d *deleteCredentialCmd) resolveFlags(cmd *cobra.Command) (inputConfig, err
provider, err := cmd.Flags().GetString(providerFlagName)
if err != nil {
return inputConfig{}, err
} else if provider == "" {
return inputConfig{}, errors.New("please provide a value for 'provider'")
}
return inputConfig{provider}, nil
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/cmd/delete_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func TestDeleteCredential(t *testing.T) {
}
}

func TestDeleteCredentialViaPrompt(t *testing.T) {
func TestDeleteCredentialFormula(t *testing.T) {
homeDir := os.TempDir()
ritHomeDir := filepath.Join(homeDir, ".rit")
credentialPath := filepath.Join(ritHomeDir, "credentials", env.Default)
Expand Down Expand Up @@ -326,6 +326,11 @@ func TestDeleteCredentialViaPrompt(t *testing.T) {
name: "execute flag with success",
args: "--provider=github",
},
{
name: "execute flag with empty provider fail",
args: "--provider=",
wantErr: "please provide a value for 'provider'",
},
{
name: "fail on input list error",
wantErr: "some error",
Expand Down

0 comments on commit ccbf9f2

Please sign in to comment.