fakeServer = ghttp.NewServer() logger = lagertest.NewTestLogger("test") logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.INFO)) }) AfterEach(func() { fakeServer.Close() }) Describe("HandleCompletedTask", func() { var ( callbackURL string taskDB *dbFakes.FakeTaskDB statusCodes chan int reqCount chan struct{} task *models.Task httpClient *http.Client ) BeforeEach(func() { httpClient = cf_http.NewClient() statusCodes = make(chan int) reqCount = make(chan struct{}) fakeServer.RouteToHandler("POST", "/the-callback/url", func(w http.ResponseWriter, req *http.Request) { w.WriteHeader(<-statusCodes) }) callbackURL = fakeServer.URL() + "/the-callback/url"
"github.com/cloudfoundry-incubator/bbs/handlers" "github.com/cloudfoundry-incubator/bbs/models" "github.com/cloudfoundry-incubator/bbs/models/test/model_helpers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-golang/lager" ) var _ = Describe("Task Handlers", func() { var ( logger lager.Logger fakeTaskDB *fakes.FakeTaskDB responseRecorder *httptest.ResponseRecorder handler *handlers.TaskHandler task1 models.Task task2 models.Task requestBody interface{} request *http.Request ) BeforeEach(func() { fakeTaskDB = new(fakes.FakeTaskDB) logger = lager.NewLogger("test") logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG)) responseRecorder = httptest.NewRecorder() handler = handlers.NewTaskHandler(logger, fakeTaskDB) })
"net/url" "github.com/cloudfoundry-incubator/bbs/db/fakes" "github.com/cloudfoundry-incubator/bbs/handlers" "github.com/cloudfoundry-incubator/bbs/models" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-golang/lager" ) var _ = Describe("Task Handlers", func() { var ( logger lager.Logger fakeTaskDB *fakes.FakeTaskDB responseRecorder *httptest.ResponseRecorder handler *handlers.TaskHandler task1 models.Task task2 models.Task ) BeforeEach(func() { fakeTaskDB = new(fakes.FakeTaskDB) logger = lager.NewLogger("test") logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG)) responseRecorder = httptest.NewRecorder() handler = handlers.NewTaskHandler(logger, fakeTaskDB) }) Describe("Tasks", func() { var request *http.Request