本文整理汇总了Golang中github.com/dmaze/goordinate/coordinate.WorkUnit.WorkSpec方法的典型用法代码示例。如果您正苦于以下问题:Golang WorkUnit.WorkSpec方法的具体用法?Golang WorkUnit.WorkSpec怎么用?Golang WorkUnit.WorkSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dmaze/goordinate/coordinate.WorkUnit
的用法示例。
在下文中一共展示了WorkUnit.WorkSpec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestTrivialWorkUnitFlow
// TestTrivialWorkUnitFlow tests work unit creation, deletion, and existence.
func (s *Suite) TestTrivialWorkUnitFlow(c *check.C) {
var (
count int
err error
spec coordinate.WorkSpec
unit coordinate.WorkUnit
units map[string]coordinate.WorkUnit
)
spec, err = s.Namespace.SetWorkSpec(map[string]interface{}{
"name": "spec",
"min_gb": 1,
})
c.Assert(err, check.IsNil)
unit, err = spec.AddWorkUnit("unit", map[string]interface{}{}, 0)
c.Assert(err, check.IsNil)
c.Check(unit.Name(), check.Equals, "unit")
c.Check(unit.WorkSpec().Name(), check.Equals, "spec")
unit, err = spec.WorkUnit("unit")
c.Assert(err, check.IsNil)
c.Check(unit.Name(), check.Equals, "unit")
c.Check(unit.WorkSpec().Name(), check.Equals, "spec")
units, err = spec.WorkUnits(coordinate.WorkUnitQuery{})
c.Assert(err, check.IsNil)
c.Check(units, check.HasLen, 1)
c.Check(units["unit"], check.NotNil)
c.Check(units["unit"].Name(), check.Equals, "unit")
c.Check(units["unit"].WorkSpec().Name(), check.Equals, "spec")
count, err = spec.DeleteWorkUnits(coordinate.WorkUnitQuery{})
c.Assert(err, check.IsNil)
c.Check(count, check.Equals, 1)
unit, err = spec.WorkUnit("unit")
c.Assert(err, check.IsNil)
c.Check(unit, check.IsNil)
units, err = spec.WorkUnits(coordinate.WorkUnitQuery{})
c.Assert(err, check.IsNil)
c.Check(units, check.HasLen, 0)
}