Minor code maintenance for ModelStore (#492)

This commit is contained in:
ashmrtn 2022-08-05 08:49:44 -07:00 committed by GitHub
parent 97113aa80b
commit 133314ebaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -70,7 +70,7 @@ func tagsForModelWithID(
tags map[string]string, tags map[string]string,
) (map[string]string, error) { ) (map[string]string, error) {
if !s.Valid() { if !s.Valid() {
return nil, errors.New("unrecognized model schema") return nil, errors.WithStack(errUnrecognizedSchema)
} }
if len(id) == 0 { if len(id) == 0 {
@ -182,7 +182,7 @@ func (ms *ModelStore) GetIDsForType(
tags map[string]string, tags map[string]string,
) ([]*model.BaseModel, error) { ) ([]*model.BaseModel, error) {
if !s.Valid() { if !s.Valid() {
return nil, errors.New("unrecognized model schema") return nil, errors.WithStack(errUnrecognizedSchema)
} }
if _, ok := tags[stableIDKey]; ok { if _, ok := tags[stableIDKey]; ok {
@ -222,7 +222,7 @@ func (ms *ModelStore) getModelStoreID(
id model.StableID, id model.StableID,
) (manifest.ID, error) { ) (manifest.ID, error) {
if !s.Valid() { if !s.Valid() {
return "", errors.New("unrecognized model schema") return "", errors.WithStack(errUnrecognizedSchema)
} }
if len(id) == 0 { if len(id) == 0 {

View File

@ -144,8 +144,7 @@ func (suite *ModelStoreIntegrationSuite) TestBadModelTypeErrors() {
require.NoError(t, suite.m.Put(suite.ctx, model.BackupOpSchema, foo)) require.NoError(t, suite.m.Put(suite.ctx, model.BackupOpSchema, foo))
_, err := suite.m.GetIDsForType(suite.ctx, model.UnknownSchema, nil) _, err := suite.m.GetIDsForType(suite.ctx, model.UnknownSchema, nil)
require.Error(t, err) assert.ErrorIs(t, err, errUnrecognizedSchema)
assert.Contains(t, err.Error(), "schema")
} }
func (suite *ModelStoreIntegrationSuite) TestBadTypeErrors() { func (suite *ModelStoreIntegrationSuite) TestBadTypeErrors() {