(t *testing.T)
| 1417 | } |
| 1418 | |
| 1419 | func TestObject_Every(t *testing.T) { |
| 1420 | t.Run("check value", func(t *testing.T) { |
| 1421 | reporter := newMockReporter(t) |
| 1422 | object := NewObject(reporter, map[string]interface{}{ |
| 1423 | "foo": "123", |
| 1424 | "bar": "456", |
| 1425 | "baz": "b", |
| 1426 | }) |
| 1427 | |
| 1428 | invoked := 0 |
| 1429 | object.Every(func(_ string, value *Value) { |
| 1430 | invoked++ |
| 1431 | value.String().NotEmpty() |
| 1432 | }) |
| 1433 | |
| 1434 | assert.Equal(t, 3, invoked) |
| 1435 | object.chain.assert(t, success) |
| 1436 | }) |
| 1437 | |
| 1438 | t.Run("check key", func(t *testing.T) { |
| 1439 | reporter := newMockReporter(t) |
| 1440 | object := NewObject(reporter, map[string]interface{}{ |
| 1441 | "foo": "123", |
| 1442 | "bar": "456", |
| 1443 | "baz": "b", |
| 1444 | }) |
| 1445 | |
| 1446 | invoked := 0 |
| 1447 | object.Every(func(key string, value *Value) { |
| 1448 | if v, ok := value.Raw().(string); ok { |
| 1449 | invoked++ |
| 1450 | switch v { |
| 1451 | case "123": |
| 1452 | assert.Equal(t, "foo", key) |
| 1453 | case "456": |
| 1454 | assert.Equal(t, "bar", key) |
| 1455 | case "baz": |
| 1456 | assert.Equal(t, "baz", key) |
| 1457 | } |
| 1458 | } |
| 1459 | }) |
| 1460 | |
| 1461 | assert.Equal(t, 3, invoked) |
| 1462 | object.chain.assert(t, success) |
| 1463 | }) |
| 1464 | |
| 1465 | t.Run("empty object", func(t *testing.T) { |
| 1466 | reporter := newMockReporter(t) |
| 1467 | object := NewObject(reporter, map[string]interface{}{}) |
| 1468 | |
| 1469 | invoked := 0 |
| 1470 | object.Every(func(_ string, value *Value) { |
| 1471 | invoked++ |
| 1472 | value.String().NotEmpty() |
| 1473 | }) |
| 1474 | |
| 1475 | assert.Equal(t, 0, invoked) |
| 1476 | object.chain.assert(t, success) |
nothing calls this directly
no test coverage detected
searching dependent graphs…