github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/cmd/juju/model/constraints_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package model_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/model" 11 "github.com/juju/juju/testing" 12 ) 13 14 type ModelConstraintsCommandsSuite struct { 15 testing.FakeJujuXDGDataHomeSuite 16 } 17 18 var _ = gc.Suite(&ModelConstraintsCommandsSuite{}) 19 20 func (s *ModelConstraintsCommandsSuite) 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(model.NewModelSetConstraintsCommand(), 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 *ModelConstraintsCommandsSuite) 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(model.NewModelGetConstraintsCommand(), 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 }