File: entity_test.go

package info (click to toggle)
golang-github-kong-go-kong 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 620 kB
  • sloc: sh: 18; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 612 bytes parent folder | download
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"))
}