Skip to content
Browse files

Merge branch '0.2.1'

  • Loading branch information...
2 parents 581e07d + dee5007 commit b8ec6c6390a6ddbd402f85dd33a6fcb8555aeef9 @mbostock mbostock committed Apr 30, 2012
Showing with 32 additions and 12 deletions.
  1. +1 −1 lib/cube/event.js
  2. +1 −1 package.json
  3. +30 −10 test/collector-test.js
View
2 lib/cube/event.js
@@ -28,7 +28,7 @@ exports.putter = function(db) {
timesToInvalidateByTierByType = {};
function putter(request, callback) {
- var time = new Date(request.time),
+ var time = "time" in request ? new Date(request.time) : new Date(),
type = request.type;
// Validate the date and type.
View
2 package.json
@@ -1,6 +1,6 @@
{
"name": "cube",
- "version": "0.2.0",
+ "version": "0.2.1",
"description": "A system for analyzing time series data using MongoDB and Node.",
"keywords": ["time series"],
"homepage": "http://square.github.com/cube/",
View
40 test/collector-test.js
@@ -12,13 +12,6 @@ var port = ++test.port, server = cube.server({
"http-port": port
});
-var obj = { type: "test"
- , time: (new Date).toISOString()
- , data: { foo: "bar" }
- };
-var arr = [obj];
-var num = 42;
-
server.register = cube.collector.register;
server.start();
@@ -35,7 +28,13 @@ suite.addBatch(test.batch({
suite.addBatch(test.batch({
"POST /event/put with a JSON object": {
- topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify(obj)),
+ topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify({
+ type: "test",
+ time: new Date,
+ data: {
+ foo: "bar"
+ }
+ })),
"responds with status 400": function(response) {
assert.equal(response.statusCode, 400);
assert.deepEqual(JSON.parse(response.body), {error: "TypeError: Object #<Object> has no method 'forEach'"});
@@ -45,7 +44,13 @@ suite.addBatch(test.batch({
suite.addBatch(test.batch({
"POST /event/put with a JSON array": {
- topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify(arr)),
+ topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify([{
+ type: "test",
+ time: new Date,
+ data: {
+ foo: "bar"
+ }
+ }])),
"responds with status 200": function(response) {
assert.equal(response.statusCode, 200);
assert.deepEqual(JSON.parse(response.body), {});
@@ -55,12 +60,27 @@ suite.addBatch(test.batch({
suite.addBatch(test.batch({
"POST /event/put with a JSON number": {
- topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify(num)),
+ topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify(42)),
"responds with status 400": function(response) {
assert.equal(response.statusCode, 400);
assert.deepEqual(JSON.parse(response.body), {error: "TypeError: Object 42 has no method 'forEach'"});
}
}
}));
+suite.addBatch(test.batch({
+ "POST /event/put without an associated time": {
+ topic: test.request({method: "POST", port: port, path: "/1.0/event/put"}, JSON.stringify([{
+ type: "test",
+ data: {
+ foo: "bar"
+ }
+ }])),
+ "responds with status 200": function(response) {
+ assert.equal(response.statusCode, 200);
+ assert.deepEqual(JSON.parse(response.body), {});
+ }
+ }
+}));
+
suite.export(module);

0 comments on commit b8ec6c6

Please sign in to comment.
Something went wrong with that request. Please try again.