UNPKG

1.15 kBtext/coffeescriptView Raw
1streams = require './streams'
2
3describe 'import', ->
4
5 es = stdin = stdout = stderr = cmd = null
6
7 beforeEach ->
8 decache './trans.js'
9 {es} = require('./mock-all')()
10 stdin = streams.bulk()
11 stdout = streams.output()
12 stderr = streams.output()
13 cmd = require('../src/cmd')(stdin, stdout, stderr)
14
15 afterEach ->
16 mock.stopAll()
17
18 describe 'with -t ./trans.js', ->
19
20 it 'import a transformed bulk into es', ->
21 cmd ['import', '-t', './test/trans.js', 'http://localhost:9200']
22 streams.promise(stdin).then ->
23 assert.deepEqual es().bulk.args[0][0], body:[
24 {
25 create:
26 _id: 'panda id'
27 _index: 'panda index'
28 _type: 'panda type'
29 }
30 {
31 uid: '0ea74996-f3f9-5a88-ba19-f5ea93afa833'
32 name: 'Dr. Leah F. Parker'
33 address: '362 Rurel Way'
34 panda: 'TRUE PANDA'
35 }
36 ]