stream/mts/meta_test.go: added TestDeleteKeyAbsent to check that we get correct err when we try to delete data of key that doesn't exist

This commit is contained in:
saxon 2019-01-27 18:24:26 +10:30
parent c16f144372
commit 7fc2b76e6b
2 changed files with 9 additions and 2 deletions

View File

@ -83,7 +83,7 @@ func (m *Meta) Delete(key string) error {
delete(m.data, key) delete(m.data, key)
return nil return nil
} }
return errors.New("Trying to delete map entry that doesn't exist") return errKeyAbsent
} }
func (m *Meta) Encode() []byte { func (m *Meta) Encode() []byte {

View File

@ -99,7 +99,14 @@ func TestDelete(t *testing.T) {
t.Errorf("Did not expect error: %v", err.Error()) t.Errorf("Did not expect error: %v", err.Error())
} }
if _, err := meta.Get("loc"); err != errKeyAbsent { if _, err := meta.Get("loc"); err != errKeyAbsent {
t.Errorf("Did not get expected err: %v", errKeyAbsent) t.Errorf("Did not get expected err: %v", errKeyAbsent.Error())
}
}
func TestDeleteAbsentKey(t *testing.T) {
meta := NewMeta()
if err := meta.Delete("loc"); err != errKeyAbsent {
t.Errorf("Did not get expected err: %v", errKeyAbsent.Error())
} }
} }