NetworkMapper: networkMapper, } payload = models.CNIDelPayload{ InterfaceName: "some-interface-name", ContainerNamespace: "/some/container/namespace/path", ContainerID: "some-container-id", } }) It("gets the network id from the datastore", func() { err := controller.Del(payload) Expect(err).NotTo(HaveOccurred()) Expect(datastore.GetCallCount()).To(Equal(1)) containerID := datastore.GetArgsForCall(0) Expect(containerID).To(Equal("some-container-id")) }) Context("when getting the record from the datastore fails", func() { BeforeEach(func() { datastore.GetReturns(models.Container{}, errors.New("some error")) }) It("aborts and returns a wrapped error", func() { err := controller.Del(payload) Expect(err).To(MatchError("datastore get: some error")) Expect(networkMapper.GetVNICallCount()).To(Equal(0)) }) })