예제 #1
0
파일: gateway_test.go 프로젝트: nttlabs/cli
	)

	BeforeEach(func() {
		currentTime = time.Unix(0, 0)
		clock = func() time.Time { return currentTime }
		config = testconfig.NewRepository()

		ccGateway = NewCloudControllerGateway(config, clock, &testterm.FakeUI{})
		ccGateway.PollingThrottle = 3 * time.Millisecond
		uaaGateway = NewUAAGateway(config, &testterm.FakeUI{})
	})

	Describe("async timeout", func() {
		Context("when the config has a positive async timeout", func() {
			It("inherits the async timeout from the config", func() {
				config.SetAsyncTimeout(9001)
				ccGateway = NewCloudControllerGateway((config), time.Now, &testterm.FakeUI{})
				Expect(ccGateway.AsyncTimeout()).To(Equal(9001 * time.Minute))
			})
		})
	})

	Describe("Connection errors", func() {
		var oldNewHttpClient func(tr *http.Transport) HttpClientInterface

		BeforeEach(func() {
			client = &fakes.FakeHttpClientInterface{}

			oldNewHttpClient = NewHttpClient
			NewHttpClient = func(tr *http.Transport) HttpClientInterface {
				return client