API Docs for: 0.7.0
Show:

File: tests/bucket.js

/**
 * Unit test module
 * Test if SDK OSS API works correct
 * @module unittest
 * @namespace unittest
 * @class __global__
 */

var API = require('../api');
var util = require('../util');
var oss = new API.OSS();

/**
 * Test API.OSS putBucket
 * @method testPutBucket
 */
exports.testPutBucket = function(test){
	oss.putBucket('buckettest2',function(response){
		test.equal(response.statusCode,200);
		test.done();
	});
};

/**
 * Test API.OSS putBucketACL,there were three conditions
 * <ul>
 *   <li>bucket not exist</li>
 *   <li>bucket exist without acl</li>
 *   <li>bucket exist with acl</li>
 *   <li>given an unknown acl</li>
 * </ul>
 *
 * @method testPutBucketACL
 */
exports.testPutBucketACL1 = function(test){
	oss.putBucketACL('buckettest3','public-read',function(response){
		test.equal(response.statusCode,200);
		test.done();
	});
};
exports.testPutBucketACL2 = function(test){
	oss.putBucketACL('buckettest2','public-read',function(response){
		test.equal(response.statusCode,200);
		test.done();
	});
};
exports.testPutBucketACL3 = function(test){
	oss.putBucketACL('buckettest2','public-read-write',function(response){
		test.equal(response.statusCode,200);
		test.done();
	});
};
exports.testPutBucketACL4 = function(test){
	test.throws(function(){
		oss.putBucketACL('buckettest2','unknow-stuff',function(){});
	});
	test.done();
};

/**
 * Test API.OSS getBucket
 * TODO : try to use prefix,marker,delimiter,max-keys
 * @method testGetBucket
 */
exports.testGetBucket = function(test){
	oss.getBucket('buckettest2',{},function(response){
		test.equal(response.statusCode,200);
		test.done();
	});
};

/**
 * Test API.OSS getBucketACL
 * @method testGetBucketACL
 */
exports.testGetBucketACL = function(test){
	oss.getBucketACL('buckettest2',function(response){
		response.setEncoding('utf8');
		response.on('data',function(chunk){
			util.testDebugOutput('testGetBucketACL','chunk',chunk);
			test.equal(response.statusCode,200)
			test.done();
		});
	});
};

/**
 * Test API.OSS deleteBucket
 * @method testDeleteBucket
 */
exports.testDeleteBucket = function(test){
	oss.deleteBucket('buckettest2',function(response){
		test.equal(response.statusCode,204)
		test.done();
	});
};