1 /**
  2  * @fileOverview Live Container tests.
  3  */
  4 
  5 /**
  6  * @name test.live.container
  7  */
  8 (function () {
  9   var assert = require('assert'),
 10     async = require('async'),
 11     utils = require("./utils"),
 12     Tests;
 13 
 14   /**
 15    * @exports Tests as test.live.container.Tests
 16    * @namespace
 17    */
 18   Tests = {};
 19 
 20   Tests["Connection (w/ 1 Blob)"] = utils.createTestSetup([
 21     "blob001.txt"
 22   ], {
 23     "DELETE non-empty container.": function (test, opts) {
 24       var self = this,
 25         request = self.container.del();
 26 
 27       test.expect(1);
 28       request.on('error', function (err) {
 29         test.deepEqual(err.isNotEmpty(), true);
 30         test.done();
 31       });
 32       request.on('end', function (results) {
 33         test.ok(false, "Should not have completion. Got: " + results);
 34         test.done();
 35       });
 36       request.end();
 37     }
 38   });
 39 
 40   Tests["Container (w/ Blobs)"] = utils.createTestSetup([
 41     "foo/blob001.txt",
 42     "foo/blob002.txt",
 43     "foo/blob003.txt",
 44     "foo/zed/blob005.txt"
 45   ], {
 46     "GET list of blobs (maxResults).": function (test, opts) {
 47       var self = this,
 48         request = self.container.getBlobs({ maxResults: 2 });
 49 
 50       test.expect(6);
 51       request.on('error', utils.errHandle(test));
 52       request.on('end', function (results) {
 53         test.ok(results.blobs, "Should have results.");
 54         test.deepEqual(2, results.blobs.length);
 55         test.deepEqual("foo/blob001.txt", results.blobs[0].name);
 56         test.deepEqual("foo/blob002.txt", results.blobs[1].name);
 57 
 58         test.ok(results.dirNames, []);
 59 
 60         test.ok(results.hasNext, "Should have next.");
 61         test.done();
 62       });
 63       request.end();
 64     },
 65     "GET list of blobs (prefix, delim, marker).": function (test, opts) {
 66       var self = this,
 67         request = self.container.getBlobs({
 68           prefix: "foo/",
 69           delimiter: "/",
 70           marker: "foo/blob001.txt"
 71         });
 72 
 73       test.expect(6);
 74       request.on('error', utils.errHandle(test));
 75       request.on('end', function (results) {
 76         test.ok(results.blobs, "Should have results.");
 77         test.deepEqual(2, results.blobs.length);
 78         test.deepEqual("foo/blob002.txt", results.blobs[0].name);
 79         test.deepEqual("foo/blob003.txt", results.blobs[1].name);
 80 
 81         test.ok(results.dirNames, ["zed"]);
 82 
 83         test.ok(!results.hasNext, "Should not have next.");
 84         test.done();
 85       });
 86       request.end();
 87     }
 88   });
 89 
 90   module.exports.Tests = Tests;
 91 }());
 92