Expect(err).NotTo(HaveOccurred()) Expect(sbox.LockCallCount()).To(Equal(1)) Expect(sbox.UnlockCallCount()).To(Equal(1)) }) It("counts the veth devices inside the sandbox", func() { err := cleanupSandboxCommand.Execute(context) Expect(err).NotTo(HaveOccurred()) Expect(sbox.VethDeviceCountCallCount()).To(Equal(1)) }) Context("when counting the veth devices fails", func() { BeforeEach(func() { sbox.VethDeviceCountReturns(0, errors.New("some error")) }) It("wraps and returns an error", func() { err := cleanupSandboxCommand.Execute(context) Expect(err).To(MatchError("counting veth devices: some error")) }) }) Context("when there is STILL a veth device in the sandbox", func() { BeforeEach(func() { sbox.VethDeviceCountReturns(1, nil) }) It("does NOT destroy the namespace", func() { err := cleanupSandboxCommand.Execute(context)