From 7fc2b76e6b3230c8fa82d94d842d9d9006284a10 Mon Sep 17 00:00:00 2001 From: saxon Date: Sun, 27 Jan 2019 18:24:26 +1030 Subject: [PATCH] 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 --- stream/mts/meta.go | 2 +- stream/mts/meta_test.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stream/mts/meta.go b/stream/mts/meta.go index c1e29ab0..1f482790 100644 --- a/stream/mts/meta.go +++ b/stream/mts/meta.go @@ -83,7 +83,7 @@ func (m *Meta) Delete(key string) error { delete(m.data, key) return nil } - return errors.New("Trying to delete map entry that doesn't exist") + return errKeyAbsent } func (m *Meta) Encode() []byte { diff --git a/stream/mts/meta_test.go b/stream/mts/meta_test.go index 70795a28..6c81e4c5 100644 --- a/stream/mts/meta_test.go +++ b/stream/mts/meta_test.go @@ -99,7 +99,14 @@ func TestDelete(t *testing.T) { t.Errorf("Did not expect error: %v", err.Error()) } 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()) } }