本文整理汇总了Golang中github.com/juju/juju/constraints.Value.String方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.String方法的具体用法?Golang Value.String怎么用?Golang Value.String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/constraints.Value
的用法示例。
在下文中一共展示了Value.String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSetConstraints
func (s *BootstrapSuite) TestSetConstraints(c *gc.C) {
tcons := constraints.Value{Mem: uint64p(2048), CpuCores: uint64p(2)}
_, cmd, err := s.initBootstrapCommand(c, nil,
"--env-config", s.b64yamlEnvcfg,
"--instance-id", string(s.instanceId),
"--constraints", tcons.String(),
)
c.Assert(err, jc.ErrorIsNil)
err = cmd.Run(nil)
c.Assert(err, jc.ErrorIsNil)
st, err := state.Open(testing.EnvironmentTag, &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{gitjujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
Password: testPasswordHash(),
}, mongo.DefaultDialOpts(), environs.NewStatePolicy())
c.Assert(err, jc.ErrorIsNil)
defer st.Close()
cons, err := st.EnvironConstraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, gc.DeepEquals, tcons)
machines, err := st.AllMachines()
c.Assert(err, jc.ErrorIsNil)
c.Assert(machines, gc.HasLen, 1)
cons, err = machines[0].Constraints()
c.Assert(err, jc.ErrorIsNil)
c.Assert(cons, gc.DeepEquals, tcons)
}
示例2: assertUnitsMigrated
func (s *MigrationImportSuite) assertUnitsMigrated(c *gc.C, cons constraints.Value) {
exported, pwd := s.Factory.MakeUnitReturningPassword(c, &factory.UnitParams{
Constraints: cons,
})
err := exported.SetMeterStatus("GREEN", "some info")
c.Assert(err, jc.ErrorIsNil)
err = exported.SetWorkloadVersion("amethyst")
c.Assert(err, jc.ErrorIsNil)
err = s.State.SetAnnotations(exported, testAnnotations)
c.Assert(err, jc.ErrorIsNil)
s.primeStatusHistory(c, exported, status.Active, 5)
s.primeStatusHistory(c, exported.Agent(), status.Idle, 5)
_, newSt := s.importModel(c)
importedApplications, err := newSt.AllApplications()
c.Assert(err, jc.ErrorIsNil)
c.Assert(importedApplications, gc.HasLen, 1)
importedUnits, err := importedApplications[0].AllUnits()
c.Assert(err, jc.ErrorIsNil)
c.Assert(importedUnits, gc.HasLen, 1)
imported := importedUnits[0]
c.Assert(imported.UnitTag(), gc.Equals, exported.UnitTag())
c.Assert(imported.PasswordValid(pwd), jc.IsTrue)
version, err := imported.WorkloadVersion()
c.Assert(err, jc.ErrorIsNil)
c.Assert(version, gc.Equals, "amethyst")
exportedMachineId, err := exported.AssignedMachineId()
c.Assert(err, jc.ErrorIsNil)
importedMachineId, err := imported.AssignedMachineId()
c.Assert(err, jc.ErrorIsNil)
c.Assert(importedMachineId, gc.Equals, exportedMachineId)
// Confirm machine Principals are set.
exportedMachine, err := s.State.Machine(exportedMachineId)
c.Assert(err, jc.ErrorIsNil)
importedMachine, err := newSt.Machine(importedMachineId)
c.Assert(err, jc.ErrorIsNil)
s.AssertMachineEqual(c, importedMachine, exportedMachine)
meterStatus, err := imported.GetMeterStatus()
c.Assert(err, jc.ErrorIsNil)
c.Assert(meterStatus, gc.Equals, state.MeterStatus{state.MeterGreen, "some info"})
s.assertAnnotations(c, newSt, imported)
s.checkStatusHistory(c, exported, imported, 5)
s.checkStatusHistory(c, exported.Agent(), imported.Agent(), 5)
s.checkStatusHistory(c, exported.WorkloadVersionHistory(), imported.WorkloadVersionHistory(), 1)
newCons, err := imported.Constraints()
c.Assert(err, jc.ErrorIsNil)
// Can't test the constraints directly, so go through the string repr.
c.Assert(newCons.String(), gc.Equals, cons.String())
}