本文整理匯總了Golang中github.com/hashicorp/nomad/nomad/structs.Allocation.AllocModifyIndex方法的典型用法代碼示例。如果您正苦於以下問題:Golang Allocation.AllocModifyIndex方法的具體用法?Golang Allocation.AllocModifyIndex怎麽用?Golang Allocation.AllocModifyIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hashicorp/nomad/nomad/structs.Allocation
的用法示例。
在下文中一共展示了Allocation.AllocModifyIndex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestDiffAllocs
func TestDiffAllocs(t *testing.T) {
t.Parallel()
alloc1 := mock.Alloc() // Ignore
alloc2 := mock.Alloc() // Update
alloc2u := new(structs.Allocation)
*alloc2u = *alloc2
alloc2u.AllocModifyIndex += 1
alloc3 := mock.Alloc() // Remove
alloc4 := mock.Alloc() // Add
exist := []*structs.Allocation{
alloc1,
alloc2,
alloc3,
}
update := &allocUpdates{
pulled: map[string]*structs.Allocation{
alloc2u.ID: alloc2u,
alloc4.ID: alloc4,
},
filtered: map[string]struct{}{
alloc1.ID: struct{}{},
},
}
result := diffAllocs(exist, update)
if len(result.ignore) != 1 || result.ignore[0] != alloc1 {
t.Fatalf("Bad: %#v", result.ignore)
}
if len(result.added) != 1 || result.added[0] != alloc4 {
t.Fatalf("Bad: %#v", result.added)
}
if len(result.removed) != 1 || result.removed[0] != alloc3 {
t.Fatalf("Bad: %#v", result.removed)
}
if len(result.updated) != 1 {
t.Fatalf("Bad: %#v", result.updated)
}
if result.updated[0].exist != alloc2 || result.updated[0].updated != alloc2u {
t.Fatalf("Bad: %#v", result.updated)
}
}