コード例 #1
0
var _ = Describe("TaskHandler", func() {
	var (
		logger           lager.Logger
		fakeBBS          *fake_bbs.FakeReceptorBBS
		responseRecorder *httptest.ResponseRecorder
		handler          *handlers.TaskHandler
		request          *http.Request
	)

	BeforeEach(func() {
		fakeBBS = new(fake_bbs.FakeReceptorBBS)
		logger = lager.NewLogger("test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
		responseRecorder = httptest.NewRecorder()
		handler = handlers.NewTaskHandler(fakeBBS, logger)
	})

	Describe("Create", func() {
		validCreateRequest := receptor.TaskCreateRequest{
			TaskGuid:   "task-guid-1",
			Domain:     "test-domain",
			RootFS:     "docker://docker",
			Action:     &models.RunAction{Path: "/bin/bash", Args: []string{"echo", "hi"}},
			MemoryMB:   24,
			DiskMB:     12,
			CPUWeight:  10,
			LogGuid:    "guid",
			LogSource:  "source-name",
			ResultFile: "result-file",
			Annotation: "some annotation",
コード例 #2
0
var _ = Describe("TaskHandler", func() {
	var (
		logger           lager.Logger
		fakeClient       *fake_bbs.FakeClient
		responseRecorder *httptest.ResponseRecorder
		handler          *handlers.TaskHandler
		request          *http.Request
	)

	BeforeEach(func() {
		fakeClient = &fake_bbs.FakeClient{}
		logger = lager.NewLogger("test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
		responseRecorder = httptest.NewRecorder()
		handler = handlers.NewTaskHandler(fakeClient, logger)
	})

	Describe("Create", func() {
		var validCreateRequest receptor.TaskCreateRequest
		var expectedTask *models.Task

		BeforeEach(func() {
			validCreateRequest = receptor.TaskCreateRequest{
				TaskGuid:   "task-guid-1",
				Domain:     "test-domain",
				RootFS:     "docker://docker",
				Action:     models.WrapAction(&models.RunAction{User: "******", Path: "/bin/bash", Args: []string{"echo", "hi"}}),
				MemoryMB:   24,
				DiskMB:     12,
				CPUWeight:  10,