Expect(datastore.CreateCallCount()).To(Equal(1)) Expect(datastore.CreateArgsForCall(0)).To(Equal(models.Container{ ID: "container-id", NetworkID: "network-id-1", App: "app-id-1", MAC: "00:00:00:00:00", HostIP: "10.12.100.4", IP: "192.168.160.3", })) }) It("gets the networkID from the network mapper", func() { _, err := controller.Add(payload) Expect(err).NotTo(HaveOccurred()) Expect(networkMapper.GetNetworkIDCallCount()).To(Equal(1)) Expect(networkMapper.GetNetworkIDArgsForCall(0)).To(Equal(payload.Network)) }) Context("when getting the network ID fails", func() { BeforeEach(func() { networkMapper.GetNetworkIDReturns("", errors.New("potato")) }) It("should return an meaningful error", func() { _, err := controller.Add(payload) Expect(err).To(MatchError("get network id: potato")) }) }) It("uses the network id to get the VNI", func() {