MCPcopy
hub / github.com/elastic/go-elasticsearch / TestBulkIndexerItem

Function TestBulkIndexerItem

esutil/bulk_indexer_internal_test.go:1661–1689  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1659}
1660
1661func 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
1691type customJSONDecoder struct {
1692 err error

Callers

nothing calls this directly

Calls 3

marshallMetaMethod · 0.95
computeLengthMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected