(t *testing.T)
| 37 | } |
| 38 | |
| 39 | func 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 | |
| 68 | func TestQueryAttributes3(t *testing.T) { |
| 69 | attributes := []*base.Attribute{ |
nothing calls this directly
no test coverage detected