Skip to content

Commit

Permalink
return error from DeleteMachine in eventually blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas016 committed Mar 21, 2024
1 parent d560d5f commit 1e7e3db
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions provider/server/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ var _ = Describe("Exec", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).To(SatisfyAny(
BeNil(),
MatchError(ContainSubstring("NotFound")),
))
}).Should(Succeed())
return err
}).Should(SatisfyAny(
BeNil(),
MatchError(ContainSubstring("NotFound")),
))
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
return libvirt.IsNotFound(err)
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_annotations_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var _ = Describe("UpdateMachineAnnotations", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
16 changes: 8 additions & 8 deletions provider/server/machine_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ var _ = Describe("CreateMachine", func() {
))

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down Expand Up @@ -158,9 +158,9 @@ var _ = Describe("CreateMachine", func() {
))

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down Expand Up @@ -274,9 +274,9 @@ var _ = Describe("CreateMachine", func() {
))

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down Expand Up @@ -404,9 +404,9 @@ var _ = Describe("CreateMachine", func() {
))

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ var _ = Describe("ListMachine", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_networkinterface_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ var _ = Describe("AttachNetworkInterface", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_networkinterface_detach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ var _ = Describe("DetachNetworkInterface", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_powerstate_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ var _ = Describe("UpdateMachinePower", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_volume_attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ var _ = Describe("AttachVolume", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down
4 changes: 2 additions & 2 deletions provider/server/machine_volume_detach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ var _ = Describe("DetachVolume", func() {
Expect(createResp).NotTo(BeNil())

DeferCleanup(func(ctx SpecContext) {
Eventually(func(g Gomega) {
Eventually(func() error {
_, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id})
g.Expect(err).Should(Succeed())
return err
}).Should(Succeed())
Eventually(func() bool {
_, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id))
Expand Down

0 comments on commit 1e7e3db

Please sign in to comment.