✨ Add Get method to Metas type
This commit is contained in:
parent
8f585bf7d2
commit
cccac79439
2 changed files with 26 additions and 0 deletions
|
|
@ -141,3 +141,19 @@ func TestMetasAppendTo(t *testing.T) {
|
|||
assert.Len(t, *ms, 1)
|
||||
assert.Equal(t, Meta{"foo", 42}, (*ms)[0])
|
||||
}
|
||||
|
||||
func TestMetasGet(t *testing.T) {
|
||||
ms := Metas{{"foo", 42}, {"bar", "hello"}}
|
||||
|
||||
val, found := ms.Get("foo")
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, 42, val)
|
||||
|
||||
val, found = ms.Get("bar")
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, "hello", val)
|
||||
|
||||
val, found = ms.Get("baz")
|
||||
assert.False(t, found)
|
||||
assert.Nil(t, val)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue