mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 18:44:54 +08:00

* Unified Storage: Return an already exists error When inserting a resource that already exists (i.e. race condition), we can safely catch UNIQUE constraint violations and transform them into a `k8s.io/apimachinery/pkg/api/errors` error that stands the test of `errors.IsAlreadyExists`. * feat: clarify existing conflict error * chore: make update-workspace * feat: make new package for backend error * fix: assign dependency owner * feat: use dialect for checking error type * chore: go generate * revert: to 5af369166d6
15 lines
354 B
Go
15 lines
354 B
Go
package backend
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
|
)
|
|
|
|
func TestErrResourceAlreadyExistsIsRecognisable(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
require.True(t, apierrors.IsAlreadyExists(ErrResourceAlreadyExists), "ErrResourceAlreadyExists should be recognised as an AlreadyExists error")
|
|
}
|