mirror of https://bitbucket.org/ausocean/av.git
stream/mts/meta: meta.Delete no longer returns error - updated code accordingly
This commit is contained in:
parent
a94bdbfe47
commit
db3b34c10f
|
@ -124,7 +124,7 @@ func (m *Data) Get(key string) (val string, ok bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete deletes a meta entry in the map and returns error if it doesn’t exist.
|
// Delete deletes a meta entry in the map and returns error if it doesn’t exist.
|
||||||
func (m *Data) Delete(key string) error {
|
func (m *Data) Delete(key string) {
|
||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
if _, ok := m.data[key]; ok {
|
if _, ok := m.data[key]; ok {
|
||||||
|
@ -136,9 +136,9 @@ func (m *Data) Delete(key string) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
return errKeyAbsent
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode takes the meta data map and encodes into a byte slice with header
|
// Encode takes the meta data map and encodes into a byte slice with header
|
||||||
|
|
|
@ -108,23 +108,12 @@ func TestGetAbsentKey(t *testing.T) {
|
||||||
func TestDelete(t *testing.T) {
|
func TestDelete(t *testing.T) {
|
||||||
meta := New()
|
meta := New()
|
||||||
meta.Add(tstKey1, tstData1)
|
meta.Add(tstKey1, tstData1)
|
||||||
if err := meta.Delete(tstKey1); err != nil {
|
meta.Delete(tstKey1)
|
||||||
t.Errorf("Unexpected err: %v\n", err)
|
|
||||||
}
|
|
||||||
if _, ok := meta.Get(tstKey1); ok {
|
if _, ok := meta.Get(tstKey1); ok {
|
||||||
t.Error("Get incorrectly returned okay for absent key")
|
t.Error("Get incorrectly returned okay for absent key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestDeleteAbsentKey checks that we get an expected error when we try to delete
|
|
||||||
// an entry in the Meta map that doesn't exist.
|
|
||||||
func TestDeleteAbsentKey(t *testing.T) {
|
|
||||||
meta := New()
|
|
||||||
if err := meta.Delete(tstKey1); err != errKeyAbsent {
|
|
||||||
t.Errorf("Not expected err: %v\n", errKeyAbsent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestEncode checks that we're getting the correct byte slice from Meta.Encode().
|
// TestEncode checks that we're getting the correct byte slice from Meta.Encode().
|
||||||
func TestEncode(t *testing.T) {
|
func TestEncode(t *testing.T) {
|
||||||
meta := New()
|
meta := New()
|
||||||
|
|
Loading…
Reference in New Issue