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

Function TestAttributeCollection

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

Source from the content-addressed store, hash-verified

91}
92
93func TestAttributeCollection(t *testing.T) {
94 // Create a new AttributeCollection with two attributes
95 attr1, err := attribute.Attribute("book:b1$status|string:published")
96 assert.NoError(t, err)
97
98 attr2, err := attribute.Attribute("book:b2$status|string:draft")
99 assert.NoError(t, err)
100
101 attrColl := NewAttributeCollection(attr1, attr2)
102
103 // Test the CreateAttributeIterator method
104 iter := attrColl.CreateAttributeIterator()
105 assert.NotNil(t, iter)
106
107 // Test the GetAttributes method
108 attributes := attrColl.GetAttributes()
109 assert.Equal(t, 2, len(attributes))
110 assert.Equal(t, attr1, attributes[0])
111 assert.Equal(t, attr2, attributes[1])
112
113 // Test the Add method
114 attr3, err := attribute.Attribute("book:b3$status|string:archived")
115 assert.NoError(t, err)
116
117 attrColl.Add(attr3)
118 attributes = attrColl.GetAttributes()
119 assert.Equal(t, 3, len(attributes))
120 assert.Equal(t, attr3, attributes[2])
121}
122
123func TestEmptyCollections(t *testing.T) {
124 // Test empty TupleCollection

Callers

nothing calls this directly

Calls 5

GetAttributesMethod · 0.95
AddMethod · 0.95
AttributeFunction · 0.92
NewAttributeCollectionFunction · 0.85

Tested by

no test coverage detected