Skip to content

Commit 8e9166b

Browse files
committed
wrote system test for subnetwork
1 parent 32bbe69 commit 8e9166b

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

system-test/compute.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,65 @@ describe('Compute', function() {
11291129
});
11301130
});
11311131

1132+
describe('subnetworks', function() {
1133+
var SUBNETWORK_NAME = generateName('subnetwork');
1134+
var subnetwork = region.subnetwork(SUBNETWORK_NAME);
1135+
1136+
var NETWORK_NAME = generateName('network');
1137+
var network = compute.network(NETWORK_NAME);
1138+
1139+
var CONFIG = {
1140+
autoCreateSubnetworks: false
1141+
};
1142+
1143+
1144+
let SUBNETWORK_CONFIG = {
1145+
network: 'global/networks/' + NETWORK_NAME,
1146+
ipCidrRange: '10.0.1.0/24'
1147+
};
1148+
1149+
before(function(done) {
1150+
async.series([
1151+
create(network, CONFIG),
1152+
create(subnetwork, SUBNETWORK_CONFIG)
1153+
], done);
1154+
});
1155+
1156+
it('should have created the subnetwork', function(done) {
1157+
subnetwork.getMetadata(function(err, metadata) {
1158+
assert.ifError(err);
1159+
assert.strictEqual(metadata.name, SUBNETWORK_NAME);
1160+
done();
1161+
});
1162+
});
1163+
1164+
it('should get a list of subnetworks', function(done) {
1165+
compute.getSubnetworks(function(err, subnetworks) {
1166+
assert.ifError(err);
1167+
assert(subnetworks.length > 0);
1168+
done();
1169+
});
1170+
});
1171+
1172+
it('should get a list of subnetworks in stream mode', function(done) {
1173+
var resultsMatched = 0;
1174+
1175+
compute.getSubnetworks()
1176+
.on('error', done)
1177+
.on('data', function() {
1178+
resultsMatched++;
1179+
})
1180+
.on('end', function() {
1181+
assert(resultsMatched > 0);
1182+
done();
1183+
});
1184+
});
1185+
1186+
it('should access a subnetwork through a Region', function(done) {
1187+
region.subnetwork(SUBNETWORK_NAME).getMetadata(done);
1188+
});
1189+
});
1190+
11321191
function generateName(customPrefix) {
11331192
return TESTS_PREFIX + customPrefix + '-' + Date.now();
11341193
}
@@ -1154,6 +1213,7 @@ describe('Compute', function() {
11541213
'getDisks',
11551214
'getInstanceGroups',
11561215
'getFirewalls',
1216+
'getSubnetworks',
11571217
'getHealthChecks',
11581218
'getNetworks',
11591219
'getRules',

0 commit comments

Comments
 (0)