From 9eaf8afb6f2bfaf0d844a64d4d263f557f197489 Mon Sep 17 00:00:00 2001 From: Michael Gaffney Date: Mon, 1 Jun 2020 09:54:02 -0400 Subject: [PATCH] Rename db.IsUnique to db.IsUniqueError (#90) --- internal/db/error.go | 4 ++-- internal/db/error_test.go | 2 +- internal/host/static/repository.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/db/error.go b/internal/db/error.go index ce54b023e6..f88d7ec5cc 100644 --- a/internal/db/error.go +++ b/internal/db/error.go @@ -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 } diff --git a/internal/db/error_test.go b/internal/db/error_test.go index 128065a50c..b31b2f3762 100644 --- a/internal/db/error_test.go +++ b/internal/db/error_test.go @@ -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) }) } diff --git a/internal/host/static/repository.go b/internal/host/static/repository.go index d8d27f0ed5..392974a9e7 100644 --- a/internal/host/static/repository.go +++ b/internal/host/static/repository.go @@ -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) }