Skip to content

Commit d53072d

Browse files
chux0519stephenplusplus
authored andcommitted
fix: snapshot.delete() no longer throws (#251)
1 parent 225544e commit d53072d

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/google-cloud-compute/src/snapshot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class Snapshot extends common.ServiceObject {
176176
* @name Snapshot#compute
177177
* @type {Compute}
178178
*/
179-
this.compute = isDisk ? scope.compute : scope;
179+
this.compute = isDisk ? scope.zone.compute : scope;
180180
/**
181181
* @name Snapshot#name
182182
* @type {string}

packages/google-cloud-compute/system-test/compute.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,13 @@ describe('Compute', () => {
206206
return zone.disk(DISK_NAME).getMetadata();
207207
});
208208

209-
it('should take a snapshot', async () => {
209+
it('should take and delete a snapshot', async () => {
210210
const [snapshot, operation] = await disk
211211
.snapshot(generateName('snapshot'))
212212
.create();
213213
await operation.promise();
214214
await snapshot.getMetadata();
215+
await snapshot.delete();
215216
});
216217

217218
it('should run operation as a promise', async () => {

packages/google-cloud-compute/test/snapshot.js

+5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,16 @@ describe('Snapshot', function() {
9595
assert.strictEqual(this, scope);
9696
done();
9797
},
98+
zone: {
99+
compute: COMPUTE,
100+
},
98101
};
99102

100103
const snapshot = new Snapshot(scope, SNAPSHOT_NAME);
101104
assert(snapshot instanceof ServiceObject);
102105

106+
assert.strictEqual(snapshot.compute, scope.zone.compute);
107+
103108
const calledWith = snapshot.calledWith_[0];
104109
assert.strictEqual(calledWith.methods.create, true);
105110

0 commit comments

Comments
 (0)