Netns:       "/some/namespace/path",
					IfName:      "interface-name",
					Args:        "FOO=BAR;ABC=123",
					StdinData: []byte(`{
						"network": {
							"network_id": "",
							"properties": {
								"app_id": "some-app-id"
							}
						}
					}`),
				})
				Expect(err).NotTo(HaveOccurred())

				Expect(marshaler.MarshalCallCount()).To(Equal(1))
				Expect(marshaler.MarshalArgsForCall(0)).To(Equal(expectedCNIPayload))
			})
		})

		Context("when network is omitted", func() {
			BeforeEach(func() {
				expectedCNIPayload = models.CNIAddPayload{
					Args:               "FOO=BAR;ABC=123",
					ContainerNamespace: "/some/namespace/path",
					InterfaceName:      "interface-name",
					ContainerID:        "some-container-id",
				}

				server.AppendHandlers(ghttp.CombineHandlers(
					ghttp.VerifyRequest("POST", "/cni/add"),
					ghttp.VerifyJSONRepresenting(expectedCNIPayload),
		var receivedContainers []models.Container
		err = json.Unmarshal(resp.Body.Bytes(), &receivedContainers)
		Expect(err).NotTo(HaveOccurred())

		Expect(resp.Code).To(Equal(http.StatusOK))
		Expect(receivedContainers).To(ConsistOf(containers))
	})

	It("should marshal the containers received from the datastore", func() {
		req, err := http.NewRequest("GET", "/containers", nil)
		Expect(err).NotTo(HaveOccurred())
		resp := httptest.NewRecorder()
		handler.ServeHTTP(resp, req)

		Expect(marshaler.MarshalCallCount()).To(Equal(1))
		Expect(marshaler.MarshalArgsForCall(0)).To(Equal(containers))
	})

	Context("when there are no containers", func() {
		BeforeEach(func() {
			dataStore.AllReturns([]models.Container{}, nil)
		})

		It("should return an empty list", func() {
			req, err := http.NewRequest("GET", "/containers", nil)
			Expect(err).NotTo(HaveOccurred())
			resp := httptest.NewRecorder()
			handler.ServeHTTP(resp, req)

			Expect(resp.Body.String()).To(MatchJSON(`[]`))
		})