8000 Add a trivial quickie test and a convenience script. · lethalbrains/arangodb@b5c87fb · GitHub
[go: up one dir, main page]

Skip to content

Commit b5c87fb

Browse files
committed
Add a trivial quickie test and a convenience script.
1 parent 1d8c7e4 commit b5c87fb

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
/*jshint globalstrict:false, strict:false, sub: true */
2+
/*global fail, assertTrue, assertEqual */
3+
4+
////////////////////////////////////////////////////////////////////////////////
5+
/// @brief very quick test for basic functionality
6+
///
7+
/// @file
8+
///
9+
/// DISCLAIMER
10+
///
11+
/// Copyright 2016-2016 ArangoDB GmbH, Cologne, Germany
12+
///
13+
/// Licensed under the Apache License, Version 2.0 (the "License");
14+
/// you may not use this file except in compliance with the License.
15+
/// You may obtain a copy of the License at
16+
///
17+
/// http://www.apache.org/licenses/LICENSE-2.0
18+
///
19+
/// Unless required by applicable law or agreed to in writing, software
20+
/// distributed under the License is distributed on an "AS IS" BASIS,
21+
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
/// See the License for the specific language governing permissions and
23+
/// limitations under the License.
24+
///
25+
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
26+
///
27+
/// @author Max Neunhoeffer
28+
/// @author Copyright 2016, ArangoDB GmbH, Cologne, Germany
29+
////////////////////////////////////////////////////////////////////////////////
30+
31+
var jsunity = require("jsunity");
32+
var arangodb = require("@arangodb");
33+
var ERRORS = arangodb.errors;
34+
var db = arangodb.db;
35+
36+
////////////////////////////////////////////////////////////////////////////////
37+
/// @brief test attributes
38+
////////////////////////////////////////////////////////////////////////////////
39+
40+
function QuickieSuite () {
41+
'use strict';
42+
43+
return {
44+
45+
////////////////////////////////////////////////////////////////////////////////
46+
/// @brief set up
47+
////////////////////////////////////////////////////////////////////////////////
48+
49+
setUp : function () {
50+
},
51+
52+
////////////////////////////////////////////////////////////////////////////////
53+
/// @brief tear down
54+
////////////////////////////////////////////////////////////////////////////////
55+
56+
tearDown : function () {
57+
},
58+
59+
////////////////////////////////////////////////////////////////////////////////
60+
/// @brief quickly create a collection and do some operations:
61+
////////////////////////////////////////////////////////////////////////////////
62+
63+
testACollection: function () {
64+
65+
try {
66+
db._drop("UnitTestCollection");
67+
}
68+
catch (e) {
69+
}
70+
71+
// Create a collection:
72+
var c = db._create("UnitTestCollection", {numberOfShards:2});
73+
74+
// Do a bunch of operations:
75+
var r = c.insert({"Hallo":12});
76+
var d = c.document(r._key);
77+
assertEqual(12, d.Hallo);
78+
c.replace(r._key, {"Hallo":13});
79+
d = c.document(r._key);
80+
assertEqual(13, d.Hallo);
81+
c.update(r._key, {"Hallo":14});
82+
d = c.document(r._key);
83+
assertEqual(14, d.Hallo);
84+
c.remove(r._key);
85+
try {
86+
d = c.document(r._key);
87+
fail();
88+
}
89+
catch (e) {
90+
assertEqual(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code, e.errorNum);
91+
}
92+
93+
// Drop the collection again:
94+
c.drop();
95+
},
96+
97+
////////////////////////////////////////////////////////////////////////////////
98+
/// @brief quickly create a database and a collection and do some operations:
99+
////////////////////////////////////////////////////////////////////////////////
100+
101+
testADatabase: function () {
102+
try {
103+
db._dropDatabase("UnitTestDatabase");
104+
}
105+
catch (e) {
106+
}
107+
108+
db._createDatabase("UnitTestDatabase");
109+
db._useDatabase("UnitTestDatabase");
110+
111+
// Create a collection:
112+
var c = db._create("UnitTestCollection", {numberOfShards:2});
113+
114+
// Do a bunch of operations:
115+
var r = c.insert({"Hallo":12});
116+
var d = c.document(r._key);
117+
assertEqual(12, d.Hallo);
118+
c.replace(r._key, {"Hallo":13});
119+
d = c.document(r._key);
120+
assertEqual(13, d.Hallo);
121+
c.update(r._key, {"Hallo":14});
122+
d = c.document(r._key);
123+
assertEqual(14, d.Hallo);
124+
c.remove(r._key);
125+
try {
126+
d = c.document(r._key);
127+
fail();
128+
}
129+
catch (e) {
130+
assertEqual(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code, e.errorNum);
131+
}
132+
133+
// Drop the collection again:
134+
c.drop();
135+
136+
// Drop the database again:
137+
db._useDatabase("_system");
138+
db._dropDatabase("UnitTestDatabase");
139+
}
140+
};
141+
}
142+
143+
////////////////////////////////////////////////////////////////////////////////
144+
/// @brief executes the test suite
145+
////////////////////////////////////////////////////////////////////////////////
146+
147+
jsunity.run(QuickieSuite);
148+
149+
return jsunity.done();
150+

scripts/quickieTest.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
scripts/unittest shell_server --test js/common/tests/shell/shell-quickie.js
3+
scripts/unittest shell_server --test js/common/tests/shell/shell-quickie.js --cluster true
4+
scripts/unittest shell_client --test js/common/tests/shell/shell-quickie.js
5+
scripts/unittest shell_client --test js/common/tests/shell/shell-quickie.js --cluster true

0 commit comments

Comments
 (0)
0