Ejemplo n.º 1
0
func (s *ConstraintsSuite) TestParseConstraints(c *gc.C) {
	for i, t := range parseConstraintsTests {
		c.Logf("test %d: %s", i, t.summary)
		cons0, err := constraints.Parse(t.args...)
		if t.err == "" {
			c.Assert(err, gc.IsNil)
		} else {
			c.Assert(err, gc.ErrorMatches, t.err)
			continue
		}
		cons1, err := constraints.Parse(cons0.String())
		c.Check(err, gc.IsNil)
		c.Check(cons1, gc.DeepEquals, cons0)
	}
}
Ejemplo n.º 2
0
func (s *ConstraintsSuite) TestRoundtripString(c *gc.C) {
	for _, t := range constraintsRoundtripTests {
		c.Logf("test %s", t.Name)
		cons, err := constraints.Parse(t.Value.String())
		c.Check(err, gc.IsNil)
		c.Check(cons, gc.DeepEquals, t.Value)
	}
}
Ejemplo n.º 3
0
func (c *SetConstraintsCommand) Init(args []string) (err error) {
	if err := c.EnvCommandBase.EnsureEnvName(); err != nil {
		return err
	}
	if c.ServiceName != "" && !names.IsService(c.ServiceName) {
		return fmt.Errorf("invalid service name %q", c.ServiceName)
	}
	c.Constraints, err = constraints.Parse(args...)
	return err
}