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

Function TestEntityIterator

pkg/database/iterators_test.go:397–442  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

395}
396
397func TestEntityIterator(t *testing.T) {
398 // Create some tuples
399 en1 := &base.Entity{
400 Type: "entity",
401 Id: "e1",
402 }
403
404 en2 := &base.Entity{
405 Type: "entity",
406 Id: "e2",
407 }
408
409 en3 := &base.Entity{
410 Type: "entity",
411 Id: "e3",
412 }
413
414 // Create a entity collection and add the tuples
415 entityCollection := NewEntityCollection(en1, en2, en3)
416
417 // Create an entity iterator
418 entityIterator := entityCollection.CreateEntityIterator()
419
420 // Test HasNext() and GetNext() methods
421 if !entityIterator.HasNext() {
422 t.Error("Expected true for HasNext(), but got false")
423 }
424 if entityIterator.GetNext() != en1 {
425 t.Error("Expected tuple1 for GetNext(), but got something else")
426 }
427 if !entityIterator.HasNext() {
428 t.Error("Expected true for HasNext(), but got false")
429 }
430 if entityIterator.GetNext() != en2 {
431 t.Error("Expected tuple2 for GetNext(), but got something else")
432 }
433 if !entityIterator.HasNext() {
434 t.Error("Expected true for HasNext(), but got false")
435 }
436 if entityIterator.GetNext() != en3 {
437 t.Error("Expected tuple3 for GetNext(), but got something else")
438 }
439 if entityIterator.HasNext() {
440 t.Error("Expected false for HasNext(), but got true")
441 }
442}
443
444func TestNewSubjectIterator(t *testing.T) {
445 // Create some subjects

Callers

nothing calls this directly

Calls 5

CreateEntityIteratorMethod · 0.95
NewEntityCollectionFunction · 0.85
HasNextMethod · 0.45
ErrorMethod · 0.45
GetNextMethod · 0.45

Tested by

no test coverage detected