Пример #1
0
    it("should respawn sync process if worker killed", function* () {
      var filter = (msg, msgs) => { msg; return msgs.length >= 3; };
      var msgs = yield h.wait_msgs("sync.watcher.*", filter, () => {
        process.kill(watcher.get_worker(origin, dest).child.childData.pid);
      });

      h.expect(msgs).to.include.something.that.deep.eql(
        {"op": "restart", "status": "init"}
      );
      h.expect(msgs).to.include.something.that.deep.eql(
        {"op": "sync", "status": "done"}
      );
      h.expect(msgs).to.include.something.that.deep.eql(
        {"op": "watch", "status": "ready"}
      );

      var file = "bar/Fred.txt";
      var origin_file = path.join(origin, file);
      var dest_file   = path.join(origin, file);
      var wait_msgs   = h.wait_msg('sync.watcher.*');

      yield fsAsync.writeFile(origin_file, "foobar");

      var msg_change = yield wait_msgs;
      h.expect(msg_change).to.have.property('op', 'change');
      h.expect(msg_change).to.have.property('filepath', file);
      h.expect(msg_change).to.have.property('status', 'done');

      var content = yield fsAsync.readFile(dest_file);
      h.expect(content.toString()).to.equal("foobar");
    });
Пример #2
0
    it("should remove a watcher", function* () {
      h.expect(_.keys(watcher.workers)).to.length(1);
      var msg = yield h.wait_msg("sync.watcher.finish", null, () => {
        watcher.unwatch(origin, dest);
      });

      h.expect(_.keys(watcher.workers)).to.length(0);
      h.expect(msg).to.have.property('status', 'done');
    });
Пример #3
0
  it("should sync two folders", function* () {
    var wait_msg = h.wait_msg("sync.watcher.sync");

    var [origin, dest] = yield make_copy();
    yield watcher.watch(origin, dest);
    h.expect(_.keys(watcher.workers)).to.length(1);

    var msg = yield wait_msg;
    h.expect(msg).to.have.property('op', 'sync');
    h.expect(msg).to.have.property('status', 'done');

    var result = yield h.diff(origin, dest);
    h.expect(result).to.have.property('deviation', 3);
  });
Пример #4
0
    it("should sync two folders and watch", function* () {
      var file = "bar/Fred.txt";
      var origin_file = path.join(origin, file);
      var dest_file   = path.join(origin, file);

      var wait_msg = h.wait_msg("sync.watcher.*");
      yield fsAsync.writeFile(origin_file, "foobar");
      var msg = yield wait_msg;

      h.expect(msg).to.have.deep.property('op', 'change');
      h.expect(msg).to.have.deep.property('filepath', file);
      h.expect(msg).to.have.deep.property('status', 'done');

      var content = yield fsAsync.readFile(dest_file);
      h.expect(content.toString()).to.equal("foobar");
    });
Пример #5
0
 it("should reuse a watcher", function* () {
   var msg = yield h.wait_msg("sync.watcher.init", null, () => {
     watcher.watch(origin, dest);
   });
   h.expect(msg).to.have.property('status', 'exists');
 });