本文整理汇总了Golang中github.com/dmaze/goordinate/coordinate.WorkSpec.SetData方法的典型用法代码示例。如果您正苦于以下问题:Golang WorkSpec.SetData方法的具体用法?Golang WorkSpec.SetData怎么用?Golang WorkSpec.SetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dmaze/goordinate/coordinate.WorkSpec
的用法示例。
在下文中一共展示了WorkSpec.SetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSetDataSetsMeta
// TestSetDataSetsMeta tests that...yeah
func (s *Suite) TestSetDataSetsMeta(c *check.C) {
var (
err error
spec coordinate.WorkSpec
meta coordinate.WorkSpecMeta
)
spec, err = s.Namespace.SetWorkSpec(map[string]interface{}{
"name": "spec",
"min_gb": 1,
})
c.Assert(err, check.IsNil)
meta, err = spec.Meta(false)
c.Assert(err, check.IsNil)
c.Check(meta.Priority, check.Equals, 0)
c.Check(meta.Weight, check.Equals, 20)
c.Check(meta.Paused, check.Equals, false)
c.Check(meta.Continuous, check.Equals, false)
c.Check(meta.CanBeContinuous, check.Equals, false)
c.Check(meta.Interval, check.Equals, time.Duration(0))
c.Check(meta.NextContinuous, check.Equals, time.Time{})
c.Check(meta.MaxRunning, check.Equals, 0)
c.Check(meta.MaxAttemptsReturned, check.Equals, 0)
c.Check(meta.NextWorkSpecName, check.Equals, "")
c.Check(meta.AvailableCount, check.Equals, 0)
c.Check(meta.PendingCount, check.Equals, 0)
err = spec.SetData(map[string]interface{}{
"name": "spec",
"min_gb": 1,
"priority": 10,
"weight": 100,
"disabled": true,
"continuous": true,
"interval": 60,
"max_running": 10,
"max_getwork": 1,
"then": "spec2",
})
c.Assert(err, check.IsNil)
meta, err = spec.Meta(false)
c.Assert(err, check.IsNil)
c.Check(meta.Priority, check.Equals, 10)
c.Check(meta.Weight, check.Equals, 100)
c.Check(meta.Paused, check.Equals, true)
c.Check(meta.Continuous, check.Equals, true)
c.Check(meta.CanBeContinuous, check.Equals, true)
c.Check(meta.Interval, check.Equals, time.Duration(60)*time.Second)
c.Check(meta.NextContinuous, check.Equals, time.Time{})
c.Check(meta.MaxRunning, check.Equals, 10)
c.Check(meta.MaxAttemptsReturned, check.Equals, 1)
c.Check(meta.NextWorkSpecName, check.Equals, "spec2")
c.Check(meta.AvailableCount, check.Equals, 0)
c.Check(meta.PendingCount, check.Equals, 0)
}
示例2: TestChangeSpecData
// TestChangeSpecData tests WorkSpec.SetData().
func (s *Suite) TestChangeSpecData(c *check.C) {
var (
err error
data map[string]interface{}
spec coordinate.WorkSpec
)
spec, err = s.Namespace.SetWorkSpec(map[string]interface{}{
"name": "spec",
"min_gb": 1,
})
c.Assert(err, check.IsNil)
c.Check(spec.Name(), check.Equals, "spec")
err = spec.SetData(map[string]interface{}{
"name": "spec",
"min_gb": 2,
"foo": "bar",
})
c.Assert(err, check.IsNil)
data, err = spec.Data()
c.Assert(err, check.IsNil)
c.Check(data["name"], check.Equals, "spec")
c.Check(data["min_gb"], Like, 2)
c.Check(data["foo"], check.Equals, "bar")
err = spec.SetData(map[string]interface{}{})
c.Assert(err, check.NotNil)
c.Check(err, check.Equals, coordinate.ErrNoWorkSpecName)
err = spec.SetData(map[string]interface{}{
"name": "name",
"min_gb": 3,
})
c.Assert(err, check.NotNil)
c.Check(err, check.Equals, coordinate.ErrChangedName)
data, err = spec.Data()
c.Assert(err, check.IsNil)
c.Check(data["name"], check.Equals, "spec")
c.Check(data["min_gb"], Like, 2)
c.Check(data["foo"], check.Equals, "bar")
}