"github.com/appc/cni/pkg/types"
	"github.com/cloudfoundry-incubator/ducati-daemon/client"
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"
	"github.com/cloudfoundry-incubator/ducati-daemon/models"
	"github.com/onsi/gomega/ghttp"

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

var _ = Describe("Client", func() {
	var (
		c           client.DaemonClient
		server      *ghttp.Server
		marshaler   *lfakes.Marshaler
		unmarshaler *lfakes.Unmarshaler

		roundTripper *fakes.RoundTripper
		httpClient   *http.Client
	)

	BeforeEach(func() {
		server = ghttp.NewServer()
		marshaler = &lfakes.Marshaler{}
		unmarshaler = &lfakes.Unmarshaler{}

		roundTripper = &fakes.RoundTripper{}
		roundTripper.RoundTripStub = http.DefaultTransport.RoundTrip

		httpClient = &http.Client{
			Transport: roundTripper,
	"github.com/cloudfoundry-incubator/ducati-daemon/fakes"

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

var _ = Describe("JSON Client", func() {
	Describe("BuildAndDo", func() {
		var (
			jsonClient  client.JSONClient
			server      *ghttp.Server
			marshaler   *lfakes.Marshaler
			unmarshaler *lfakes.Unmarshaler

			roundTripper *fakes.RoundTripper
			httpClient   *http.Client

			config client.ClientConfig

			requestPayload []int
			responseResult map[string]string
		)

		BeforeEach(func() {
			server = ghttp.NewServer()
			server.AppendHandlers(ghttp.CombineHandlers(
				ghttp.VerifyRequest("POST", "/some/path"),
				ghttp.RespondWithJSONEncoded(http.StatusCreated, map[string]string{"foo": "bar"}),
			))

			marshaler = &lfakes.Marshaler{}