Skip to content

Commit

Permalink
Merge pull request #221 from nicks/nicks/pass
Browse files Browse the repository at this point in the history
pass: return an error when a cred doesn't exist
  • Loading branch information
thaJeztah authored Aug 28, 2022
2 parents 0ab1dd0 + 2fc2313 commit 2f246b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pass/pass.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (p Pass) Get(serverURL string) (string, string, error) {

if _, err := os.Stat(path.Join(getPassDir(), PASS_FOLDER, encoded)); err != nil {
if os.IsNotExist(err) {
return "", "", nil
return "", "", credentials.NewErrCredentialsNotFound()
}

return "", "", err
Expand Down
19 changes: 12 additions & 7 deletions pass/pass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ func TestPassHelper(t *testing.T) {
t.Fatal(err)
}

username, _, err = helper.Get(server)
if err != nil {
t.Fatal(err)
}

if username != "" {
t.Fatalf("%s shouldn't exist any more", username)
_, _, err = helper.Get(server)
if !credentials.IsErrCredentialsNotFound(err) {
t.Fatalf("expected credentials not found, actual: %v", err)
}
}

Expand All @@ -73,3 +69,12 @@ func TestPassHelper(t *testing.T) {
t.Fatal("didn't delete all creds?")
}
}

func TestMissingCred(t *testing.T) {
helper := Pass{}

_, _, err := helper.Get("garbage")
if !credentials.IsErrCredentialsNotFound(err) {
t.Fatalf("expected credentials not found, actual: %v", err)
}
}

0 comments on commit 2f246b8

Please sign in to comment.