Ejemplo n.º 1
0
	"code.cloudfoundry.org/bbs/db/dbfakes"
	"code.cloudfoundry.org/bbs/models"
	"code.cloudfoundry.org/bbs/models/test/model_helpers"
	"code.cloudfoundry.org/bbs/taskworkpool/taskworkpoolfakes"
	"code.cloudfoundry.org/lager/lagertest"
	"code.cloudfoundry.org/rep"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
)

var _ = Describe("Task Controller", func() {
	var (
		logger                   *lagertest.TestLogger
		fakeTaskDB               *dbfakes.FakeTaskDB
		fakeAuctioneerClient     *auctioneerfakes.FakeClient
		fakeTaskCompletionClient *taskworkpoolfakes.FakeTaskCompletionClient

		controller *controllers.TaskController
	)

	BeforeEach(func() {
		fakeTaskDB = new(dbfakes.FakeTaskDB)
		fakeAuctioneerClient = new(auctioneerfakes.FakeClient)
		fakeTaskCompletionClient = new(taskworkpoolfakes.FakeTaskCompletionClient)

		logger = lagertest.NewTestLogger("test")
		controller = controllers.NewTaskController(fakeTaskDB, fakeTaskCompletionClient, fakeAuctioneerClient, fakeServiceClient, fakeRepClientFactory)
	})

	Describe("Tasks", func() {
		var (
Ejemplo n.º 2
0
		cfhttp.Initialize(timeout)
		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
			task        *models.Task

			httpClient *http.Client
		)

		BeforeEach(func() {
			httpClient = cfhttp.NewClient()
			statusCodes = make(chan int)

			fakeServer.RouteToHandler("POST", "/the-callback/url", func(w http.ResponseWriter, req *http.Request) {
				w.WriteHeader(<-statusCodes)
			})

			callbackURL = fakeServer.URL() + "/the-callback/url"
			taskDB = new(dbfakes.FakeTaskDB)
			taskDB.ResolvingTaskReturns(nil)