"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/handlers"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	"github.com/cloudfoundry-incubator/ducati-daemon/store"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/rata"
)

var _ = Describe("GET /container/:container_id", func() {
	var (
		getHandler *handlers.GetContainer
		marshaler  *lfakes.Marshaler
		logger     *lagertest.TestLogger
		datastore  *fakes.Store
	)

	BeforeEach(func() {
		marshaler = &lfakes.Marshaler{}
		marshaler.MarshalStub = json.Marshal
		datastore = &fakes.Store{}
		logger = lagertest.NewTestLogger("test")
		getHandler = &handlers.GetContainer{
			Marshaler: marshaler,
			Logger:    logger,
			Datastore: datastore,
		}

		datastore.GetStub = func(id string) (models.Container, error) {
	lfakes "lib/fakes"
	"net/http"
	"net/http/httptest"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/handlers"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	"github.com/pivotal-golang/lager/lagertest"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("ListContainers", func() {
	var dataStore *fakes.Store
	var handler *handlers.ListContainers
	var marshaler *lfakes.Marshaler
	var containers []models.Container
	var logger *lagertest.TestLogger

	BeforeEach(func() {
		dataStore = &fakes.Store{}
		marshaler = &lfakes.Marshaler{}
		marshaler.MarshalStub = json.Marshal
		logger = lagertest.NewTestLogger("test")
		handler = &handlers.ListContainers{
			Marshaler: marshaler,
			Logger:    logger,
			Datastore: dataStore,
		}
	"github.com/appc/cni/pkg/types"
	"github.com/cloudfoundry-incubator/ducati-daemon/cni"
	"github.com/cloudfoundry-incubator/ducati-daemon/container"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CniAdd", func() {
	var (
		datastore     *fakes.Store
		ipamResult    *types.Result
		creator       *fakes.Creator
		controller    *cni.AddController
		ipAllocator   *fakes.IPAllocator
		networkMapper *fakes.NetworkMapper
		payload       models.CNIAddPayload
	)

	BeforeEach(func() {
		datastore = &fakes.Store{}
		creator = &fakes.Creator{}

		ipAllocator = &fakes.IPAllocator{}
		networkMapper = &fakes.NetworkMapper{}

		controller = &cni.AddController{
			Datastore:     datastore,
			Creator:       creator,
	"net"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	"github.com/cloudfoundry-incubator/ducati-daemon/watcher"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
)

var _ = Describe("Resolver", func() {
	var (
		drainer               watcher.Resolver
		logger                *lagertest.TestLogger
		missesChannel         chan watcher.Neighbor
		fakeStore             *fakes.Store
		knownNeighborsChannel chan watcher.Neighbor
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		missesChannel = make(chan watcher.Neighbor)
		knownNeighborsChannel = make(chan watcher.Neighbor)
		fakeStore = &fakes.Store{}

		drainer = watcher.Resolver{
			Logger: logger,
			Store:  fakeStore,
		}
import (
	"errors"

	"github.com/cloudfoundry-incubator/ducati-daemon/cni"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CniDel", func() {
	var (
		datastore     *fakes.Store
		deletor       *fakes.Deletor
		controller    *cni.DelController
		ipAllocator   *fakes.IPAllocator
		networkMapper *fakes.NetworkMapper
		payload       models.CNIDelPayload
	)

	BeforeEach(func() {
		datastore = &fakes.Store{}
		deletor = &fakes.Deletor{}
		ipAllocator = &fakes.IPAllocator{}
		networkMapper = &fakes.NetworkMapper{}

		networkMapper.GetVNIReturns(42, nil)
		datastore.GetReturns(models.Container{
			NetworkID: "some-network-id",
		}, nil)
	"net/http/httptest"

	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/handlers"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/rata"
)

var _ = Describe("GET /networks/:network_id", func() {
	var (
		getHandler *handlers.NetworksListContainers
		marshaler  *lfakes.Marshaler
		logger     *lagertest.TestLogger
		datastore  *fakes.Store
	)

	BeforeEach(func() {
		marshaler = &lfakes.Marshaler{}
		marshaler.MarshalStub = json.Marshal
		datastore = &fakes.Store{}
		logger = lagertest.NewTestLogger("test")
		getHandler = &handlers.NetworksListContainers{
			Marshaler: marshaler,
			Logger:    logger,
			Datastore: datastore,
		}

		datastore.AllReturns([]models.Container{