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.
|
||||
func (m *Data) Delete(key string) error {
|
||||
func (m *Data) Delete(key string) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if _, ok := m.data[key]; ok {
|
||||
|
@ -136,9 +136,9 @@ func (m *Data) Delete(key string) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
return errKeyAbsent
|
||||
return
|
||||
}
|
||||
|
||||
// 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) {
|
||||
meta := New()
|
||||
meta.Add(tstKey1, tstData1)
|
||||
if err := meta.Delete(tstKey1); err != nil {
|
||||
t.Errorf("Unexpected err: %v\n", err)
|
||||
}
|
||||
meta.Delete(tstKey1)
|
||||
if _, ok := meta.Get(tstKey1); ok {
|
||||
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().
|
||||
func TestEncode(t *testing.T) {
|
||||
meta := New()
|
||||
|
|
Loading…
Reference in New Issue