MCPcopy Create free account
hub / github.com/Permify/permify / TestEntityCollection

Function TestEntityCollection

pkg/database/collections_test.go:69–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

67}
68
69func TestEntityCollection(t *testing.T) {
70 // Create a new EntityCollection with two entities
71 entity1 := &base.Entity{Type: "book", Id: "b1"}
72 entity2 := &base.Entity{Type: "book", Id: "b2"}
73 entityColl := NewEntityCollection(entity1, entity2)
74
75 // Test the CreateEntityIterator method
76 iter := entityColl.CreateEntityIterator()
77 assert.NotNil(t, iter)
78
79 // Test the GetEntities method
80 entities := entityColl.GetEntities()
81 assert.Equal(t, 2, len(entities))
82 assert.Equal(t, entity1, entities[0])
83 assert.Equal(t, entity2, entities[1])
84
85 // Test the Add method
86 entity3 := &base.Entity{Type: "book", Id: "b3"}
87 entityColl.Add(entity3)
88 entities = entityColl.GetEntities()
89 assert.Equal(t, 3, len(entities))
90 assert.Equal(t, entity3, entities[2])
91}
92
93func TestAttributeCollection(t *testing.T) {
94 // Create a new AttributeCollection with two attributes

Callers

nothing calls this directly

Calls 4

CreateEntityIteratorMethod · 0.95
GetEntitiesMethod · 0.95
AddMethod · 0.95
NewEntityCollectionFunction · 0.85

Tested by

no test coverage detected