1 | streams = require './streams'
|
2 |
|
3 | describe 'import', ->
|
4 |
|
5 | es = stdin = stdout = stderr = cmd = null
|
6 |
|
7 | beforeEach ->
|
8 | {es} = require('./mock-all')()
|
9 | stdin = streams.u0085()
|
10 | stdout = streams.output()
|
11 | stderr = streams.output()
|
12 | cmd = require('../src/cmd')(stdin, stdout, stderr)
|
13 |
|
14 | afterEach ->
|
15 | mock.stopAll()
|
16 |
|
17 | describe 'of a bad u0085 char', ->
|
18 | it 'import bulk to es without overrides', ->
|
19 | cmd ['import', 'http://localhost:9200']
|
20 | streams.promise(stdin).then ->
|
21 | assert.deepEqual es().bulk.args[0][0],
|
22 | {
|
23 | body:[
|
24 | {index:{_id:'id-second', _index:'myindex', _type:'mytype'}}
|
25 | {body_text:'Second.Test 123 '}
|
26 | ]
|
27 | }
|
28 | assert.deepEqual stderr.getContentsAsString?('utf8'), COMPARE.join('')
|
29 |
|
30 | COMPARE = [
|
31 | "Skipping record, JSON parse failed (Unexpected end of JSON input) on line after:\n"
|
32 | "{\"index\":{\"_index\":\"myindex\",\"_type\":\"mytype\",\"_id\":\"id-first\"}}\n"
|
33 | "Imported 1\n"
|
34 | ]
|