File: tsv1.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (32 lines) | stat: -rw-r--r-- 877 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// tsv1.js

t = new ToolTest( "tsv1" )

c = t.startDB( "foo" );

base = { a : "", b : 1 , c : "foobar" , d: 5, e: -6 };

t.runTool( "import" , "--file" , "jstests/tool/data/a.tsv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "tsv" , "-f" , "a,b,c,d,e" );
assert.soon( "2 == c.count()" , "restore 2" );

a = c.find().sort( { a : 1 } ).toArray();
delete a[0]._id
delete a[1]._id

assert.eq( { a : "a" , b : "b" , c : "c" , d: "d", e: "e"} , a[1] , "tsv parse 1" );
assert.eq( base , a[0] , "tsv parse 0" )

c.drop()
assert.eq( 0 , c.count() , "after drop 2" )

t.runTool( "import" , "--file" , "jstests/tool/data/a.tsv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "tsv" , "--headerline" )
assert.soon( "c.findOne()" , "no data after sleep" );
assert.eq( 1 , c.count() , "after restore 2" );

x = c.findOne()
delete x._id;
assert.eq( base , x , "tsv parse 2" )



t.stop()