github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/cmd/juju/environment/constraints_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environment_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/cmd/juju/environment" 11 "github.com/juju/juju/testing" 12 ) 13 14 type EnvConstraintsCommandsSuite struct { 15 testing.FakeJujuHomeSuite 16 } 17 18 var _ = gc.Suite(&EnvConstraintsCommandsSuite{}) 19 20 func (s *EnvConstraintsCommandsSuite) TestSetInit(c *gc.C) { 21 for _, test := range []struct { 22 args []string 23 err string 24 }{ 25 { 26 args: []string{"-s", "mysql"}, 27 err: "flag provided but not defined: -s", 28 }, { 29 args: []string{"="}, 30 err: `malformed constraint "="`, 31 }, { 32 args: []string{"cpu-power=250"}, 33 }, 34 } { 35 err := testing.InitCommand(&environment.EnvSetConstraintsCommand{}, test.args) 36 if test.err == "" { 37 c.Check(err, jc.ErrorIsNil) 38 } else { 39 c.Check(err, gc.ErrorMatches, test.err) 40 } 41 } 42 } 43 44 func (s *EnvConstraintsCommandsSuite) TestGetInit(c *gc.C) { 45 for _, test := range []struct { 46 args []string 47 err string 48 }{ 49 { 50 args: []string{"-s", "mysql"}, 51 err: "flag provided but not defined: -s", 52 }, { 53 args: []string{"mysql"}, 54 err: `unrecognized args: \["mysql"\]`, 55 }, { 56 args: []string{}, 57 }, 58 } { 59 err := testing.InitCommand(&environment.EnvGetConstraintsCommand{}, test.args) 60 if test.err == "" { 61 c.Check(err, jc.ErrorIsNil) 62 } else { 63 c.Check(err, gc.ErrorMatches, test.err) 64 } 65 } 66 }