コード例 #1
0
	"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,
コード例 #2
0
	"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{}