MCPcopy Create free account
hub / github.com/olivere/elastic / TestBulkCreateRequestSerialization

Function TestBulkCreateRequestSerialization

bulk_create_request_test.go:12–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestBulkCreateRequestSerialization(t *testing.T) {
13 tests := []struct {
14 Request BulkableRequest
15 Expected []string
16 }{
17 // #0
18 {
19 Request: NewBulkCreateRequest().Index("index1").Id("1").
20 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
21 Expected: []string{
22 `{"create":{"_index":"index1","_id":"1"}}`,
23 `{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
24 },
25 },
26 // #1
27 {
28 Request: NewBulkCreateRequest().Index("index1").Id("1").
29 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
30 Expected: []string{
31 `{"create":{"_index":"index1","_id":"1"}}`,
32 `{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
33 },
34 },
35 // #2
36 {
37 Request: NewBulkCreateRequest().Index("index1").Id("1").RetryOnConflict(42).
38 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
39 Expected: []string{
40 `{"create":{"_index":"index1","_id":"1","retry_on_conflict":42}}`,
41 `{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
42 },
43 },
44 // #3
45 {
46 Request: NewBulkCreateRequest().Index("index1").Id("1").Pipeline("my_pipeline").
47 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
48 Expected: []string{
49 `{"create":{"_index":"index1","_id":"1","pipeline":"my_pipeline"}}`,
50 `{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
51 },
52 },
53 // #4
54 {
55 Request: NewBulkCreateRequest().Index("index1").Id("1").
56 Routing("123").
57 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
58 Expected: []string{
59 `{"create":{"_index":"index1","_id":"1","routing":"123"}}`,
60 `{"user":"olivere","message":"","retweets":0,"created":"2014-01-18T23:59:58Z"}`,
61 },
62 },
63 // #5
64 {
65 Request: NewBulkCreateRequest().Index("index1").Type("doc").Id("1").
66 Version(0).
67 VersionType("external").
68 Doc(tweet{User: "olivere", Created: time.Date(2014, 1, 18, 23, 59, 58, 0, time.UTC)}),
69 Expected: []string{

Callers

nothing calls this directly

Calls 13

NewBulkCreateRequestFunction · 0.85
FatalfMethod · 0.80
ErrorfMethod · 0.80
TypeMethod · 0.65
SourceMethod · 0.65
DocMethod · 0.45
IdMethod · 0.45
IndexMethod · 0.45
RetryOnConflictMethod · 0.45
PipelineMethod · 0.45
RoutingMethod · 0.45
VersionTypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…