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

Function TestQueryAttributes2

internal/storage/context/attributes_test.go:39–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestQueryAttributes2(t *testing.T) {
40 attributes := []*base.Attribute{
41 {Entity: &base.Entity{Type: "type1", Id: "1"}, Attribute: "attribute1", Value: nil},
42 {Entity: &base.Entity{Type: "type3", Id: "3"}, Attribute: "attribute2", Value: nil},
43 {Entity: &base.Entity{Type: "type5", Id: "5"}, Attribute: "attribute3", Value: nil},
44 }
45
46 contextualAttributes := NewContextualAttributes(attributes...)
47 filter := &base.AttributeFilter{Entity: &base.EntityFilter{Type: "type3", Ids: []string{"3"}}, Attributes: []string{"attribute1", "attribute2"}}
48
49 iterator, err := contextualAttributes.QueryAttributes(filter, database.NewCursorPagination())
50 if err != nil {
51 t.Errorf("Unexpected error: %v", err)
52 }
53
54 if !iterator.HasNext() {
55 t.Errorf("Expected at least one attributes, got none")
56 }
57
58 filteredTuple := iterator.GetNext()
59 if filteredTuple.Entity.Type != "type3" || filteredTuple.Entity.Id != "3" || filteredTuple.Attribute != "attribute2" {
60 t.Errorf("Unexpected attribute: %+v", filteredTuple)
61 }
62
63 if iterator.HasNext() {
64 t.Errorf("Expected exactly one attribute, got more")
65 }
66}
67
68func TestQueryAttributes3(t *testing.T) {
69 attributes := []*base.Attribute{

Callers

nothing calls this directly

Calls 5

QueryAttributesMethod · 0.95
NewCursorPaginationFunction · 0.92
NewContextualAttributesFunction · 0.85
HasNextMethod · 0.45
GetNextMethod · 0.45

Tested by

no test coverage detected