Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adding test_sync.js

  • Loading branch information...
commit fb06e1ce616380b986152ecbf5aefd7284eb1830 1 parent e218afc
John Wright authored June 14, 2010

Showing 1 changed file with 70 additions and 0 deletions. Show diff stats Hide diff stats

  1. 70  test/test_sync.js
70  test/test_sync.js
... ...
@@ -0,0 +1,70 @@
  1
+(function(){
  2
+  var assert, flow, fs, nosqlite, remove_file, sys, test_pull;
  3
+  require.paths.unshift("vendor");
  4
+  sys = require("sys");
  5
+  nosqlite = require("../lib/index");
  6
+  fs = require("fs");
  7
+  flow = require("flow");
  8
+  assert = require("assert");
  9
+  remove_file = function(file) {
  10
+    try {
  11
+      return fs.unlinkSync(file);
  12
+    } catch (err) {
  13
+      return sys.puts(err);
  14
+    }
  15
+  };
  16
+  test_pull = function() {
  17
+    var db, db_file;
  18
+    db_file = "./test/test_pull.db";
  19
+    //remove_file(db_file)
  20
+    db = nosqlite.open(db_file, {
  21
+      sync_mode: true
  22
+    }, function() {
  23
+      var log, log_desc, schema;
  24
+      log = {
  25
+        text: "hello",
  26
+        occurred_at: new Date().getTime(),
  27
+        created_at: new Date().getTime(),
  28
+        updated_at: new Date().getTime(),
  29
+        source: "string1",
  30
+        log_type: "string1",
  31
+        geo_lat: "string1",
  32
+        geo_long: "string1",
  33
+        metric: 5,
  34
+        external_id: 10,
  35
+        level: 5,
  36
+        readable_metric: "5 miles",
  37
+        facts: ["hello", "hello", "hello1"],
  38
+        original: {
  39
+          id: 1,
  40
+          text: "some crazy object"
  41
+        }
  42
+      };
  43
+      log_desc = {
  44
+        table: "log",
  45
+        objs: [log]
  46
+      };
  47
+      //create a schema
  48
+      schema = [
  49
+        {
  50
+          table: "log",
  51
+          objs: [log]
  52
+        }
  53
+      ];
  54
+      return flow.exec(function() {
  55
+        return db.create_schema(schema, this);
  56
+      }, function(err) {
  57
+        if ((typeof err !== "undefined" && err !== null)) {
  58
+          throw err;
  59
+        }
  60
+        return db.pull("http://localhost:3000/nsl/pull", "test_sync.db", this);
  61
+      }, function(err, results) {
  62
+        if ((typeof err !== "undefined" && err !== null)) {
  63
+          throw err;
  64
+        }
  65
+      });
  66
+    });
  67
+    return db;
  68
+  };
  69
+  test_pull();
  70
+})();

0 notes on commit fb06e1c

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