(t *testing.T)
| 1659 | } |
| 1660 | |
| 1661 | func TestBulkIndexerItem(t *testing.T) { |
| 1662 | body := `{"body":"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."}` |
| 1663 | t.Run("correct computeLength size", func(t *testing.T) { |
| 1664 | expectedLength := 266 |
| 1665 | bi := BulkIndexerItem{ |
| 1666 | Action: "index", |
| 1667 | DocumentID: strconv.Itoa(1), |
| 1668 | Body: strings.NewReader(body), |
| 1669 | } |
| 1670 | bi.marshallMeta() |
| 1671 | _ = bi.computeLength() |
| 1672 | if bi.payloadLength != expectedLength { |
| 1673 | t.Fatalf("invalid length, expected %d, got %d", expectedLength, bi.payloadLength) |
| 1674 | } |
| 1675 | }) |
| 1676 | t.Run("empty reader length should be meta length plus newlines", func(t *testing.T) { |
| 1677 | expectedLength := 23 |
| 1678 | bi := BulkIndexerItem{ |
| 1679 | Action: "index", |
| 1680 | DocumentID: strconv.Itoa(1), |
| 1681 | Body: strings.NewReader(""), |
| 1682 | } |
| 1683 | bi.marshallMeta() |
| 1684 | _ = bi.computeLength() |
| 1685 | if bi.payloadLength != expectedLength { |
| 1686 | t.Fatalf("invalid length, expected %d, got %d", expectedLength, bi.payloadLength) |
| 1687 | } |
| 1688 | }) |
| 1689 | } |
| 1690 | |
| 1691 | type customJSONDecoder struct { |
| 1692 | err error |
nothing calls this directly
no test coverage detected