1 | streams = require './streams'
|
2 |
|
3 | describe 'export', ->
|
4 |
|
5 | es = stdin = stdout = stderr = cmd = null
|
6 |
|
7 | beforeEach ->
|
8 | {es} = require('./mock-all')()
|
9 | stdin = streams.empty()
|
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 'with -d', ->
|
18 |
|
19 | it 'exports to delete bulk', ->
|
20 | cmd ['export', '-d', 'http://localhost:9200/myindex']
|
21 | streams.promise(stdout)
|
22 | .then (bulk) ->
|
23 | cmp = es.docs().map (d) ->
|
24 | delete:{_index:'myindex', _type:'mytype', _id:d.uid}
|
25 | .map (r) -> JSON.stringify(r)
|
26 | .join('\n') + '\n'
|
27 | assert.deepEqual bulk, cmp
|
28 | .then ->
|
29 | assert.deepEqual streams.string(stderr),
|
30 | 'Exported 10/42\nExported 20/42\nExported 30/42\nExported 40/42\nExported 42/42\n'
|