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() {
		_, err := controller.Add(payload)
		Expect(err).NotTo(HaveOccurred())

		Expect(networkMapper.GetVNICallCount()).To(Equal(1))
		Expect(networkMapper.GetVNIArgsForCall(0)).To(Equal("network-id-1"))
	})

	It("allocates an IP and returns the ipamResult", func() {
		returnedIPAMResult, err := controller.Add(payload)
		Expect(err).NotTo(HaveOccurred())

		Expect(ipAllocator.AllocateIPCallCount()).To(Equal(1))
		networkID, containerID := ipAllocator.AllocateIPArgsForCall(0)
		Expect(networkID).To(Equal("network-id-1"))
		Expect(containerID).To(Equal("container-id"))

		Expect(returnedIPAMResult).To(BeIdenticalTo(ipamResult))
	})