1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
package custom
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEntityObject(t *testing.T) {
assert := assert.New(t)
var typ Type = "foo"
var object Object = map[string]interface{}{
"id": "unique",
"key": "value",
}
e := NewEntityObject(typ)
assert.NotNil(e)
assert.Equal(typ, e.Type())
e.SetObject(object)
assert.Equal(object, e.Object())
e.AddRelation("bar", "baz")
e.AddRelation("yo", "yoyo")
assert.Equal("baz", e.GetRelation("bar"))
assert.Equal("yoyo", e.GetRelation("yo"))
assert.Equal(2, len(e.GetAllRelations()))
assert.Equal("", e.GetRelation("none"))
}
|