(t *testing.T)
| 86 | } |
| 87 | |
| 88 | func TestQueryAttributes4(t *testing.T) { |
| 89 | attributes := []*base.Attribute{ |
| 90 | {Entity: &base.Entity{Type: "type1", Id: "1"}, Attribute: "attribute1", Value: nil}, |
| 91 | {Entity: &base.Entity{Type: "type3", Id: "3"}, Attribute: "attribute2", Value: nil}, |
| 92 | {Entity: &base.Entity{Type: "type5", Id: "5"}, Attribute: "attribute3", Value: nil}, |
| 93 | {Entity: &base.Entity{Type: "type5", Id: "4"}, Attribute: "attribute4", Value: nil}, |
| 94 | {Entity: &base.Entity{Type: "type5", Id: "12"}, Attribute: "attribute12", Value: nil}, |
| 95 | {Entity: &base.Entity{Type: "type5", Id: "22"}, Attribute: "attribute22", Value: nil}, |
| 96 | } |
| 97 | |
| 98 | contextualAttributes := NewContextualAttributes(attributes...) |
| 99 | filter := &base.AttributeFilter{Entity: &base.EntityFilter{Type: "type5", Ids: []string{}}, Attributes: []string{}} |
| 100 | |
| 101 | iterator, err := contextualAttributes.QueryAttributes(filter, database.NewCursorPagination(database.Cursor("MjI="), database.Sort("entity_id"))) |
| 102 | if err != nil { |
| 103 | t.Errorf("Unexpected error: %v", err) |
| 104 | } |
| 105 | |
| 106 | if !iterator.HasNext() { |
| 107 | t.Errorf("Expected at least one attribute, got none") |
| 108 | } |
| 109 | |
| 110 | filteredAttribute := iterator.GetNext() |
| 111 | if filteredAttribute.Entity.Type != "type5" || filteredAttribute.Entity.Id != "22" || filteredAttribute.Attribute != "attribute22" { |
| 112 | t.Errorf("Unexpected attribute: %+v", filteredAttribute) |
| 113 | } |
| 114 | |
| 115 | if !iterator.HasNext() { |
| 116 | t.Errorf("Expected at least one attribute, got none") |
| 117 | } |
| 118 | |
| 119 | filteredAttribute2 := iterator.GetNext() |
| 120 | if filteredAttribute2.Entity.Type != "type5" || filteredAttribute2.Entity.Id != "4" || filteredAttribute2.Attribute != "attribute4" { |
| 121 | t.Errorf("Unexpected attribute: %+v", filteredAttribute2) |
| 122 | } |
| 123 | |
| 124 | if !iterator.HasNext() { |
| 125 | t.Errorf("Expected at least one attribute, got none") |
| 126 | } |
| 127 | |
| 128 | filteredAttribute3 := iterator.GetNext() |
| 129 | if filteredAttribute3.Entity.Type != "type5" || filteredAttribute3.Entity.Id != "5" || filteredAttribute3.Attribute != "attribute3" { |
| 130 | t.Errorf("Unexpected attribute: %+v", filteredAttribute3) |
| 131 | } |
| 132 | } |
nothing calls this directly
no test coverage detected