Skip to content

Commit

Permalink
Backfill unit test to handle error on auto delete disk.
Browse files Browse the repository at this point in the history
  • Loading branch information
Genevieve L'Esperance committed Jan 6, 2020
1 parent d188734 commit 657eded
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gcp/compute/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var _ = Describe("Instance", func() {
disks := []*gcpcompute.AttachedDisk{{DeviceName: "yogurt"}}
instance = compute.NewInstance(client, name, zone, tags, networkInterfaces, disks)
})

It("marks all with auto_delete true", func() {
err := instance.Delete()
Expect(err).NotTo(HaveOccurred())
Expand All @@ -61,6 +62,17 @@ var _ = Describe("Instance", func() {

Expect(client.DeleteInstanceCall.CallCount).To(Equal(1))
})

Context("when the client fails to mark attached disks with auto delete", func() {
BeforeEach(func() {
client.SetDiskAutoDeleteCall.Returns.Error = errors.New("ruhroh")
})

It("returns the error", func() {
err := instance.Delete()
Expect(err).To(MatchError("Set Disk Auto Delete: ruhroh"))
})
})
})

Context("when the client fails to delete", func() {
Expand Down

0 comments on commit 657eded

Please sign in to comment.