本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/build.Build.Insert方法的典型用法代码示例。如果您正苦于以下问题:Golang Build.Insert方法的具体用法?Golang Build.Insert怎么用?Golang Build.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/evergreen-ci/evergreen/model/build.Build
的用法示例。
在下文中一共展示了Build.Insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMarkAsDispatched
func TestMarkAsDispatched(t *testing.T) {
var (
taskId string
hostId string
buildId string
task *Task
myHost *host.Host
b *build.Build
)
Convey("With a task", t, func() {
taskId = "t1"
hostId = "h1"
buildId = "b1"
task = &Task{
Id: taskId,
BuildId: buildId,
}
myHost = &host.Host{
Id: hostId,
}
b = &build.Build{
Id: buildId,
Tasks: []build.TaskCache{
{Id: taskId},
},
}
testutil.HandleTestingErr(
db.ClearCollections(TasksCollection, build.Collection, host.Collection),
t, "Error clearing test collections")
So(task.Insert(), ShouldBeNil)
So(myHost.Insert(), ShouldBeNil)
So(b.Insert(), ShouldBeNil)
Convey("when marking the task as dispatched, the fields for"+
" the task, the host it is on, and the build it is a part of"+
" should be set to reflect this", func() {
// mark the task as dispatched
So(task.MarkAsDispatched(myHost, time.Now()), ShouldBeNil)
// make sure the task's fields were updated, both in memory and
// in the db
So(task.DispatchTime, ShouldNotResemble, time.Unix(0, 0))
So(task.Status, ShouldEqual, evergreen.TaskDispatched)
So(task.HostId, ShouldEqual, myHost.Id)
So(task.LastHeartbeat, ShouldResemble, task.DispatchTime)
task, err := FindTask(taskId)
So(err, ShouldBeNil)
So(task.DispatchTime, ShouldNotResemble, time.Unix(0, 0))
So(task.Status, ShouldEqual, evergreen.TaskDispatched)
So(task.HostId, ShouldEqual, myHost.Id)
So(task.LastHeartbeat, ShouldResemble, task.DispatchTime)
// make sure the build's fields were updated in the db
b, err = build.FindOne(build.ById(buildId))
So(err, ShouldBeNil)
So(b.Tasks[0].Status, ShouldEqual, evergreen.TaskDispatched)
})
})
}