✨ Some convenience methods for Metas
This commit is contained in:
parent
8086029b03
commit
79fa957d02
4 changed files with 39 additions and 16 deletions
|
|
@ -13,6 +13,8 @@ import (
|
|||
// Type assertions
|
||||
var _ encoding.TextMarshaler = Meta{}
|
||||
var _ encoding.TextUnmarshaler = new(Meta)
|
||||
var _ json.Marshaler = Metas{}
|
||||
var _ json.Unmarshaler = new(Metas)
|
||||
|
||||
var skipMarshalTest = errors.New("skip marshal")
|
||||
|
||||
|
|
@ -125,3 +127,17 @@ func TestMetasJsonError(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
assert.Len(t, ms, 0)
|
||||
}
|
||||
|
||||
func TestMetasAppend(t *testing.T) {
|
||||
ms := Metas{}
|
||||
ms = ms.Append("foo", 42)
|
||||
assert.Len(t, ms, 1)
|
||||
assert.Equal(t, Meta{"foo", 42}, ms[0])
|
||||
}
|
||||
|
||||
func TestMetasAppendTo(t *testing.T) {
|
||||
ms := &Metas{}
|
||||
ms.AppendTo("foo", 42)
|
||||
assert.Len(t, *ms, 1)
|
||||
assert.Equal(t, Meta{"foo", 42}, (*ms)[0])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue