本文整理汇总了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)
})
})
}
示例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)
})
})
}