當前位置: 首頁>>代碼示例>>Golang>>正文


Golang T.UpdateStatus方法代碼示例

本文整理匯總了Golang中testing.T.UpdateStatus方法的典型用法代碼示例。如果您正苦於以下問題:Golang T.UpdateStatus方法的具體用法?Golang T.UpdateStatus怎麽用?Golang T.UpdateStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在testing.T的用法示例。


在下文中一共展示了T.UpdateStatus方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestReconcile

func TestReconcile(t *testing.T) {
	db := eremetic.NewDefaultTaskDB()

	maxReconciliationDelay = 1

	Convey("ReconcileTasks", t, func() {
		Convey("Finishes when there are no tasks", func() {
			driver := mock.NewMesosScheduler()
			r := reconcileTasks(driver, db)

			select {
			case <-r.done:
			}

			So(driver.ReconcileTasksFnInvoked, ShouldBeFalse)
		})

		Convey("Sends reconcile request", func() {
			driver := mock.NewMesosScheduler()
			driver.ReconcileTasksFn = func(ts []*mesosproto.TaskStatus) (mesosproto.Status, error) {
				t, err := db.ReadTask("1234")
				if err != nil {
					return mesosproto.Status_DRIVER_RUNNING, err
				}
				t.UpdateStatus(eremetic.Status{
					Status: eremetic.TaskRunning,
					Time:   time.Now().Unix() + 1,
				})
				db.PutTask(&t)

				return mesosproto.Status_DRIVER_RUNNING, nil
			}

			db.PutTask(&eremetic.Task{
				ID: "1234",
				Status: []eremetic.Status{
					eremetic.Status{
						Status: eremetic.TaskStaging,
						Time:   time.Now().Unix(),
					},
				},
			})

			r := reconcileTasks(driver, db)

			select {
			case <-r.done:
			}

			So(driver.ReconcileTasksFnInvoked, ShouldBeTrue)
		})

		Convey("Cancel reconciliation", func() {
			driver := mock.NewMesosScheduler()

			db.PutTask(&eremetic.Task{
				ID: "1234",
				Status: []eremetic.Status{
					eremetic.Status{
						Status: eremetic.TaskStaging,
						Time:   time.Now().Unix(),
					},
				},
			})

			r := reconcileTasks(driver, db)
			r.Cancel()

			select {
			case <-r.done:
			}

			So(driver.ReconcileTasksFnInvoked, ShouldBeFalse)
		})
	})
}
開發者ID:klarna,項目名稱:eremetic,代碼行數:76,代碼來源:reconcile_test.go

示例2: TestReconcile

func TestReconcile(t *testing.T) {
	dir, _ := os.Getwd()
	database.NewDB(fmt.Sprintf("%s/../db/test.db", dir))
	database.Clean()
	defer database.Close()

	maxReconciliationDelay = 1

	Convey("ReconcileTasks", t, func() {
		Convey("Finishes when there are no tasks", func() {
			driver := NewMockScheduler()
			r := ReconcileTasks(driver)

			select {
			case <-r.done:
			}

			So(driver.AssertNotCalled(t, "ReconcileTasks"), ShouldBeTrue)
		})

		Convey("Sends reconcile request", func() {
			driver := NewMockScheduler()
			driver.On("ReconcileTasks").Run(func(mock.Arguments) {
				t, err := database.ReadTask("1234")
				if err != nil {
					panic("mock error")
				}
				t.UpdateStatus(types.Status{
					Status: mesos.TaskState_TASK_RUNNING.String(),
					Time:   time.Now().Unix() + 1,
				})
				database.PutTask(&t)
			}).Once()

			database.PutTask(&types.EremeticTask{
				ID: "1234",
				Status: []types.Status{
					types.Status{
						Status: mesos.TaskState_TASK_STAGING.String(),
						Time:   time.Now().Unix(),
					},
				},
			})

			r := ReconcileTasks(driver)

			select {
			case <-r.done:
			}

			So(driver.AssertCalled(t, "ReconcileTasks"), ShouldBeTrue)
		})

		Convey("Cancel reconciliation", func() {
			driver := NewMockScheduler()

			database.PutTask(&types.EremeticTask{
				ID: "1234",
				Status: []types.Status{
					types.Status{
						Status: mesos.TaskState_TASK_STAGING.String(),
						Time:   time.Now().Unix(),
					},
				},
			})

			r := ReconcileTasks(driver)
			r.Cancel()

			select {
			case <-r.done:
			}

			So(driver.AssertNotCalled(t, "ReconcileTasks"), ShouldBeTrue)
		})
	})
}
開發者ID:keis,項目名稱:eremetic,代碼行數:77,代碼來源:reconcile_test.go


注:本文中的testing.T.UpdateStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。