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

Function TestBundles

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

Source from the content-addressed store, hash-verified

169}
170
171func TestBundles(t *testing.T) {
172 // Test TupleBundle
173 tuple1 := &base.Tuple{
174 Subject: &base.Subject{Type: "user", Id: "u1"},
175 Entity: &base.Entity{Type: "book", Id: "b1"},
176 }
177 tuple2 := &base.Tuple{
178 Subject: &base.Subject{Type: "user", Id: "u2"},
179 Entity: &base.Entity{Type: "book", Id: "b2"},
180 }
181
182 tupleBundle := TupleBundle{
183 Write: *NewTupleCollection(tuple1),
184 Delete: *NewTupleCollection(tuple2),
185 }
186
187 assert.NotNil(t, tupleBundle.Write)
188 assert.NotNil(t, tupleBundle.Delete)
189 assert.Equal(t, 1, len(tupleBundle.Write.GetTuples()))
190 assert.Equal(t, 1, len(tupleBundle.Delete.GetTuples()))
191 assert.Equal(t, tuple1, tupleBundle.Write.GetTuples()[0])
192 assert.Equal(t, tuple2, tupleBundle.Delete.GetTuples()[0])
193
194 // Test AttributeBundle
195 attr1, err := attribute.Attribute("book:b1$status|string:published")
196 assert.NoError(t, err)
197
198 attr2, err := attribute.Attribute("book:b2$status|string:draft")
199 assert.NoError(t, err)
200
201 attrBundle := AttributeBundle{
202 Write: *NewAttributeCollection(attr1),
203 Delete: *NewAttributeCollection(attr2),
204 }
205
206 assert.NotNil(t, attrBundle.Write)
207 assert.NotNil(t, attrBundle.Delete)
208 assert.Equal(t, 1, len(attrBundle.Write.GetAttributes()))
209 assert.Equal(t, 1, len(attrBundle.Delete.GetAttributes()))
210 assert.Equal(t, attr1, attrBundle.Write.GetAttributes()[0])
211 assert.Equal(t, attr2, attrBundle.Delete.GetAttributes()[0])
212}

Callers

nothing calls this directly

Calls 5

AttributeFunction · 0.92
NewTupleCollectionFunction · 0.85
NewAttributeCollectionFunction · 0.85
GetTuplesMethod · 0.45
GetAttributesMethod · 0.45

Tested by

no test coverage detected