(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func 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 | |
| 39 | func TestQueryAttributes2(t *testing.T) { |
| 40 | attributes := []*base.Attribute{ |
nothing calls this directly
no test coverage detected