Skip to content

Commit

Permalink
wrote system test for subnetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
authtestprod committed Jul 15, 2016
1 parent 32bbe69 commit 8e9166b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions system-test/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,65 @@ describe('Compute', function() {
});
});

describe('subnetworks', function() {
var SUBNETWORK_NAME = generateName('subnetwork');
var subnetwork = region.subnetwork(SUBNETWORK_NAME);

var NETWORK_NAME = generateName('network');
var network = compute.network(NETWORK_NAME);

var CONFIG = {
autoCreateSubnetworks: false
};


let SUBNETWORK_CONFIG = {
network: 'global/networks/' + NETWORK_NAME,
ipCidrRange: '10.0.1.0/24'
};

before(function(done) {
async.series([
create(network, CONFIG),
create(subnetwork, SUBNETWORK_CONFIG)
], done);
});

it('should have created the subnetwork', function(done) {
subnetwork.getMetadata(function(err, metadata) {
assert.ifError(err);
assert.strictEqual(metadata.name, SUBNETWORK_NAME);
done();
});
});

it('should get a list of subnetworks', function(done) {
compute.getSubnetworks(function(err, subnetworks) {
assert.ifError(err);
assert(subnetworks.length > 0);
done();
});
});

it('should get a list of subnetworks in stream mode', function(done) {
var resultsMatched = 0;

compute.getSubnetworks()
.on('error', done)
.on('data', function() {
resultsMatched++;
})
.on('end', function() {
assert(resultsMatched > 0);
done();
});
});

it('should access a subnetwork through a Region', function(done) {
region.subnetwork(SUBNETWORK_NAME).getMetadata(done);
});
});

function generateName(customPrefix) {
return TESTS_PREFIX + customPrefix + '-' + Date.now();
}
Expand All @@ -1154,6 +1213,7 @@ describe('Compute', function() {
'getDisks',
'getInstanceGroups',
'getFirewalls',
'getSubnetworks',
'getHealthChecks',
'getNetworks',
'getRules',
Expand Down

0 comments on commit 8e9166b

Please sign in to comment.