Fixing missed error handling when merging from 0.11.1 into main (#2634)

This commit is contained in:
Todd authored and GitHub committed 2022-11-18 14:48:09 -08:00
1 parent 96a630905f
commit 35e5bcd8e5
2 files changed
+12

No files matched your search

+1
View File
@@ -519,6 +519,7 @@ func (r *WorkerAuthRepositoryStorage) FilterToAuthorizedWorkerKeyIds(ctx context
}
rows, err := r.reader.Query(ctx, authorizedWorkerQuery, []any{workerKeyIds})
if err != nil {
return nil, errors.Wrap(ctx, err, op)
}
defer rows.Close()
@@ -456,6 +456,17 @@ func TestFilterToAuthorizedWorkerKeyIds(t *testing.T) {
conn, _ := db.TestSetup(t, "postgres")
kmsCache := kms.TestKms(t, conn, rootWrapper)
t.Run("query returns error", func(t *testing.T) {
conn, mock := db.TestSetupWithMock(t)
rw := db.New(conn)
mock.ExpectQuery(`select`).WillReturnError(errors.New(context.Background(), errors.Internal, "test", "lookup-error"))
brokenRepo, err := NewRepositoryStorage(ctx, rw, rw, kmsCache)
require.NoError(t, err)
_, err = brokenRepo.FilterToAuthorizedWorkerKeyIds(ctx, []string{"something"})
assert.Error(t, err)
require.NoError(t, mock.ExpectationsWereMet())
})
// Ensures the global scope contains a valid root key
require.NoError(t, kmsCache.CreateKeys(context.Background(), scope.Global.String(), kms.WithRandomReader(rand.Reader)))