1
0
Fork 0

tests for issue #300

This commit is contained in:
Jan Steemann 2012-12-04 09:58:23 +01:00
parent 297e9bb4fd
commit 5eb0081bcd
6 changed files with 1062 additions and 1 deletions

View File

@ -406,7 +406,7 @@ unittests-import:
@echo
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --javascript.unit-tests @top_srcdir@/js/server/tests/import-setup.js || test "x$(FORCE)" == "x1"
for i in 1 2; do $(VALGRIND) @builddir@/bin/arangoimp --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --file UnitTests/import-$$i.json --collection UnitTestsImportJson$$i --type json || test "x$(FORCE)" == "x1"; done
for i in 1 2 3 4; do $(VALGRIND) @builddir@/bin/arangoimp --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --file UnitTests/import-$$i.json --collection UnitTestsImportJson$$i --type json || test "x$(FORCE)" == "x1"; done
for i in 1 2; do $(VALGRIND) @builddir@/bin/arangoimp --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --file UnitTests/import-$$i.csv --collection UnitTestsImportCsv$$i --create-collection true --type csv || test "x$(FORCE)" == "x1"; done
for i in 1 2; do $(VALGRIND) @builddir@/bin/arangoimp --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --file UnitTests/import-$$i.tsv --collection UnitTestsImportTsv$$i --create-collection true --type tsv --eol "\r\n" || test "x$(FORCE)" == "x1"; done
$(VALGRIND) @builddir@/bin/arangosh $(CLIENT_OPT) --server.username "$(USERNAME)" --server.password "$(PASSWORD)" --server.endpoint unix://$(VOCDIR)/arango.sock --javascript.unit-tests @top_srcdir@/js/server/tests/import.js || test "x$(FORCE)" == "x1"

30
UnitTests/import-3.json Normal file
View File

@ -0,0 +1,30 @@
[
{"id": 1,
"one":1,
"two": 2,
"three":
3 },
{"id": 2, "a" : 1234, "b": "the quick fox", "jumped": "over the fox", "null": null },
{"id": 3,
"spacing" :
"is",
"not":
"important" },
{"id": 4,
"a": true,
"b": false, " c " :
"h\"'ihi", "d" : ""
},
{"id" : 5 }
]

1002
UnitTests/import-4.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,8 @@ var internal = require("internal");
internal.db._drop("UnitTestsImportJson1");
internal.db._drop("UnitTestsImportJson2");
internal.db._drop("UnitTestsImportJson3");
internal.db._drop("UnitTestsImportJson4");
internal.db._drop("UnitTestsImportCsv1");
internal.db._drop("UnitTestsImportCsv2");
internal.db._drop("UnitTestsImportTsv1");
@ -36,6 +38,8 @@ internal.db._drop("UnitTestsImportTsv2");
internal.db._create("UnitTestsImportJson1");
internal.db._create("UnitTestsImportJson2");
internal.db._create("UnitTestsImportJson3");
internal.db._create("UnitTestsImportJson4");
internal.db._create("UnitTestsImportTsv1");
internal.db._create("UnitTestsImportTsv2");

View File

@ -29,6 +29,8 @@ var internal = require("internal");
internal.db._drop("UnitTestsImportJson1");
internal.db._drop("UnitTestsImportJson2");
internal.db._drop("UnitTestsImportJson3");
internal.db._drop("UnitTestsImportJson4");
internal.db._drop("UnitTestsImportCsv1");
internal.db._drop("UnitTestsImportCsv2");
internal.db._drop("UnitTestsImportTsv1");

View File

@ -129,6 +129,29 @@ function importTestSuite () {
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test json import
////////////////////////////////////////////////////////////////////////////////
testJsonImport3 : function () {
var expected = [ { "id": 1, "one": 1, "three": 3, "two": 2 }, { "a": 1234, "b": "the quick fox", "id": 2, "jumped": "over the fox", "null": null }, { "id": 3, "not": "important", "spacing": "is" }, { " c ": "h\"'ihi", "a": true, "b": false, "d": "", "id": 4 }, { "id": 5 } ];
var actual = getQueryResults("FOR i IN UnitTestsImportJson3 SORT i.id RETURN i");
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test json import
////////////////////////////////////////////////////////////////////////////////
testJsonImport4 : function () {
var expected = [ ];
for (var i = 0; i < 1000; ++i) {
expected.push({ "active": true, "id": i, "value": "somerandomstuff" + i });
}
var actual = getQueryResults("FOR i IN UnitTestsImportJson4 SORT i.id RETURN i");
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief test csv import
////////////////////////////////////////////////////////////////////////////////