Skip to content

Commit

Permalink
golint: add missing error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajnasz committed Apr 22, 2024
1 parent aff9b9a commit 5d3b870
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/models/entrykey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ func Test_EntryKeyModel_Delete(t *testing.T) {
defer db.Close()

uid, entryKeyUUID, err := createTestEntryKey(ctx, tx)
if err != nil {
if err := tx.Rollback(); err != nil {
t.Errorf("rollback failed: %v", err)
}
t.Fatal(err)
}

model := &EntryKeyModel{}

Expand Down Expand Up @@ -410,6 +416,13 @@ func Test_EntryKeyModel_UseTx(t *testing.T) {

uid, entryKeyUUID, err := createTestEntryKey(ctx, tx)

if err != nil {
if err := tx.Rollback(); err != nil {
t.Errorf("rollback failed: %v", err)
}
t.Fatal(err)
}

model := &EntryKeyModel{}

if err := model.SetMaxReads(ctx, tx, entryKeyUUID, 2); err != nil {
Expand Down
7 changes: 7 additions & 0 deletions internal/services/entrykeymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ func (e *EntryKeyManager) Create(ctx context.Context, entryUUID string, dek key.

entryKey, k, err := e.CreateWithTx(ctx, tx, entryUUID, dek, expire, maxRead)

if err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
return nil, nil, errors.Join(err, rollbackErr)
}
return nil, nil, err
}

if err := tx.Commit(); err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 5d3b870

Please sign in to comment.