本文整理匯總了Golang中github.com/juju/juju/state.Unit.SetMeterStatus方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unit.SetMeterStatus方法的具體用法?Golang Unit.SetMeterStatus怎麽用?Golang Unit.SetMeterStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.Unit
的用法示例。
在下文中一共展示了Unit.SetMeterStatus方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestWatchMeterStatus
// TestWatchMeterStatus tests the meter status watcher functionality.
func TestWatchMeterStatus(c *gc.C, status meterstatus.MeterStatus, unit *jujustate.Unit, state *jujustate.State, resources *common.Resources) {
c.Assert(resources.Count(), gc.Equals, 0)
args := params.Entities{Entities: []params.Entity{
{Tag: unit.UnitTag().String()},
{Tag: "unit-foo-42"},
}}
result, err := status.WatchMeterStatus(args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, gc.DeepEquals, params.NotifyWatchResults{
Results: []params.NotifyWatchResult{
{NotifyWatcherId: "1"},
{Error: apiservertesting.ErrUnauthorized},
},
})
// Verify the resource was registered and stop when done
c.Assert(resources.Count(), gc.Equals, 1)
resource := resources.Get("1")
defer statetesting.AssertStop(c, resource)
// Check that the Watch has consumed the initial event ("returned" in
// the Watch call)
wc := statetesting.NewNotifyWatcherC(c, state, resource.(jujustate.NotifyWatcher))
wc.AssertNoChange()
err = unit.SetMeterStatus("GREEN", "No additional information.")
c.Assert(err, jc.ErrorIsNil)
wc.AssertOneChange()
}
示例2: TestGetMeterStatus
// TestGetMeterStatus tests unit meter status retrieval.
func TestGetMeterStatus(c *gc.C, status meterstatus.MeterStatus, unit *jujustate.Unit) {
args := params.Entities{Entities: []params.Entity{{Tag: unit.Tag().String()}}}
result, err := status.GetMeterStatus(args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Results, gc.HasLen, 1)
c.Assert(result.Results[0].Error, gc.IsNil)
c.Assert(result.Results[0].Code, gc.Equals, "AMBER")
c.Assert(result.Results[0].Info, gc.Equals, "not set")
newCode := "GREEN"
newInfo := "All is ok."
err = unit.SetMeterStatus(newCode, newInfo)
c.Assert(err, jc.ErrorIsNil)
result, err = status.GetMeterStatus(args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result.Results, gc.HasLen, 1)
c.Assert(result.Results[0].Error, gc.IsNil)
c.Assert(result.Results[0].Code, gc.DeepEquals, newCode)
c.Assert(result.Results[0].Info, gc.DeepEquals, newInfo)
}