From 133314ebaa089db301d6e2e901dcd611227459de Mon Sep 17 00:00:00 2001 From: ashmrtn <3891298+ashmrtn@users.noreply.github.com> Date: Fri, 5 Aug 2022 08:49:44 -0700 Subject: [PATCH] Minor code maintenance for ModelStore (#492) --- src/internal/kopia/model_store.go | 6 +++--- src/internal/kopia/model_store_test.go | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/internal/kopia/model_store.go b/src/internal/kopia/model_store.go index 1ab0c47a7..36727ab42 100644 --- a/src/internal/kopia/model_store.go +++ b/src/internal/kopia/model_store.go @@ -70,7 +70,7 @@ func tagsForModelWithID( tags map[string]string, ) (map[string]string, error) { if !s.Valid() { - return nil, errors.New("unrecognized model schema") + return nil, errors.WithStack(errUnrecognizedSchema) } if len(id) == 0 { @@ -182,7 +182,7 @@ func (ms *ModelStore) GetIDsForType( tags map[string]string, ) ([]*model.BaseModel, error) { if !s.Valid() { - return nil, errors.New("unrecognized model schema") + return nil, errors.WithStack(errUnrecognizedSchema) } if _, ok := tags[stableIDKey]; ok { @@ -222,7 +222,7 @@ func (ms *ModelStore) getModelStoreID( id model.StableID, ) (manifest.ID, error) { if !s.Valid() { - return "", errors.New("unrecognized model schema") + return "", errors.WithStack(errUnrecognizedSchema) } if len(id) == 0 { diff --git a/src/internal/kopia/model_store_test.go b/src/internal/kopia/model_store_test.go index e00fd2b8b..75bf95d1d 100644 --- a/src/internal/kopia/model_store_test.go +++ b/src/internal/kopia/model_store_test.go @@ -144,8 +144,7 @@ func (suite *ModelStoreIntegrationSuite) TestBadModelTypeErrors() { require.NoError(t, suite.m.Put(suite.ctx, model.BackupOpSchema, foo)) _, err := suite.m.GetIDsForType(suite.ctx, model.UnknownSchema, nil) - require.Error(t, err) - assert.Contains(t, err.Error(), "schema") + assert.ErrorIs(t, err, errUnrecognizedSchema) } func (suite *ModelStoreIntegrationSuite) TestBadTypeErrors() {