Rename db.IsUnique to db.IsUniqueError (#90)

pull/91/head
Michael Gaffney 6 years ago committed by GitHub
parent 4f3f9ed222
commit 9eaf8afb6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,9 +42,9 @@ var (
ErrMultipleRecords = errors.New("multiple records")
)
// IsUnique returns a boolean indicating whether the error is known to
// IsUniqueError returns a boolean indicating whether the error is known to
// report a unique constraint violation.
func IsUnique(err error) bool {
func IsUniqueError(err error) bool {
if err == nil {
return false
}

@ -38,7 +38,7 @@ func TestError_IsUnique(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
assert := assert.New(t)
err := tt.in
got := IsUnique(err)
got := IsUniqueError(err)
assert.Equal(tt.want, got)
})
}

@ -88,7 +88,7 @@ func (r *Repository) CreateCatalog(ctx context.Context, c *HostCatalog, opt ...O
)
if err != nil {
if db.IsUnique(err) {
if db.IsUniqueError(err) {
return nil, fmt.Errorf("create: static host catalog: in scope: %s: name %s already exists: %w",
c.ScopeId, c.Name, db.ErrNotUnique)
}
@ -166,7 +166,7 @@ func (r *Repository) UpdateCatalog(ctx context.Context, c *HostCatalog, fieldMas
)
if err != nil {
if db.IsUnique(err) {
if db.IsUniqueError(err) {
return nil, db.NoRowsAffected, fmt.Errorf("update: static host catalog: %s: name %s already exists: %w",
c.PublicId, c.Name, db.ErrNotUnique)
}

Loading…
Cancel
Save