(t *testing.T)
| 216 | } |
| 217 | |
| 218 | func TestAttributeIterator(t *testing.T) { |
| 219 | isPublic, err := anypb.New(&base.BooleanValue{Data: true}) |
| 220 | assert.NoError(t, err) |
| 221 | |
| 222 | isPublic2, err := anypb.New(&base.BooleanValue{Data: false}) |
| 223 | assert.NoError(t, err) |
| 224 | |
| 225 | // Create some attributes |
| 226 | attribute1 := &base.Attribute{ |
| 227 | Entity: &base.Entity{ |
| 228 | Type: "entity", |
| 229 | Id: "e1", |
| 230 | }, |
| 231 | Attribute: "public", |
| 232 | Value: isPublic, |
| 233 | } |
| 234 | |
| 235 | attribute2 := &base.Attribute{ |
| 236 | Entity: &base.Entity{ |
| 237 | Type: "entity", |
| 238 | Id: "e2", |
| 239 | }, |
| 240 | Attribute: "public", |
| 241 | Value: isPublic2, |
| 242 | } |
| 243 | |
| 244 | attribute3 := &base.Attribute{ |
| 245 | Entity: &base.Entity{ |
| 246 | Type: "entity", |
| 247 | Id: "e3", |
| 248 | }, |
| 249 | Attribute: "public", |
| 250 | Value: isPublic, |
| 251 | } |
| 252 | |
| 253 | // Create an attribute collection and add the tuples |
| 254 | attributeCollection := NewAttributeCollection(attribute1, attribute2, attribute3) |
| 255 | |
| 256 | // Create a attribute iterator |
| 257 | attributeIterator := attributeCollection.CreateAttributeIterator() |
| 258 | |
| 259 | // Test HasNext() and GetNext() methods |
| 260 | if !attributeIterator.HasNext() { |
| 261 | t.Error("Expected true for HasNext(), but got false") |
| 262 | } |
| 263 | if attributeIterator.GetNext() != attribute1 { |
| 264 | t.Error("Expected tuple1 for GetNext(), but got something else") |
| 265 | } |
| 266 | if !attributeIterator.HasNext() { |
| 267 | t.Error("Expected true for HasNext(), but got false") |
| 268 | } |
| 269 | if attributeIterator.GetNext() != attribute2 { |
| 270 | t.Error("Expected tuple2 for GetNext(), but got something else") |
| 271 | } |
| 272 | if !attributeIterator.HasNext() { |
| 273 | t.Error("Expected true for HasNext(), but got false") |
| 274 | } |
| 275 | if attributeIterator.GetNext() != attribute3 { |
nothing calls this directly
no test coverage detected