(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…