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

Function TestQueryAttributes1

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

Source from the content-addressed store, hash-verified

8)
9
10func TestQueryAttributes1(t *testing.T) {
11 attributes := []*base.Attribute{
12 {Entity: &base.Entity{Type: "type1", Id: "1"}, Attribute: "attribute1", Value: nil},
13 {Entity: &base.Entity{Type: "type3", Id: "3"}, Attribute: "attribute2", Value: nil},
14 {Entity: &base.Entity{Type: "type5", Id: "5"}, Attribute: "attribute3", Value: nil},
15 }
16
17 contextualAttributes := NewContextualAttributes(attributes...)
18 filter := &base.AttributeFilter{Entity: &base.EntityFilter{Type: "type1", Ids: []string{"1"}}, Attributes: []string{"attribute1"}}
19
20 iterator, err := contextualAttributes.QueryAttributes(filter, database.NewCursorPagination())
21 if err != nil {
22 t.Errorf("Unexpected error: %v", err)
23 }
24
25 if !iterator.HasNext() {
26 t.Errorf("Expected at least one attribute, got none")
27 }
28
29 filteredAttribute := iterator.GetNext()
30 if filteredAttribute.Entity.Type != "type1" || filteredAttribute.Entity.Id != "1" || filteredAttribute.Attribute != "attribute1" {
31 t.Errorf("Unexpected attribute: %+v", filteredAttribute)
32 }
33
34 if iterator.HasNext() {
35 t.Errorf("Expected exactly one attribute, got more")
36 }
37}
38
39func TestQueryAttributes2(t *testing.T) {
40 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