UNPKG

1.15 kBtext/coffeescriptView Raw
1streams = require './streams'
2
3describe '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 -q ./query.json', ->
18
19 describe 'with bad file', ->
20
21 it 'reports error', ->
22 cmd ['export', '-q', './test/xxx.json', 'http://localhost:9200/myindex']
23 assert.deepEqual streams.string(stderr)
24 , 'File not found: /Users/martin/dev/ductile/test/xxx.json\n'
25
26 describe 'with good file', ->
27
28 it 'exports transformed bulk', ->
29 cmd ['export', '-q', './test/query.json', 'http://localhost:9200/myindex']
30 streams.promise(stdout).then ->
31 assert.deepEqual es().search.args[0][0],
32 body:query:fantastic_panda:true
33 index: 'myindex'
34 scroll: '60s'
35 size: 200