Пример #1
0
func (s *RemoveSuite) TestInit(c *gc.C) {
	for i, test := range []struct {
		about      string
		args       []string
		expectCIDR string
		expectErr  string
	}{{
		about:     "no arguments",
		expectErr: "CIDR is required",
	}, {
		about:     "an invalid CIDR",
		args:      s.Strings("foo"),
		expectErr: `"foo" is not a valid CIDR`,
	}, {
		about:      "too many arguments (first is valid)",
		args:       s.Strings("10.0.0.0/8", "bar", "baz"),
		expectCIDR: "10.0.0.0/8",
		expectErr:  `unrecognized args: \["bar" "baz"\]`,
	}, {
		about:     "incorrectly specified CIDR",
		args:      s.Strings("5.4.3.2/10"),
		expectErr: `"5.4.3.2/10" is not correctly specified, expected "5.0.0.0/10"`,
	}} {
		c.Logf("test #%d: %s", i, test.about)
		// Create a new instance of the subcommand for each test, but
		// since we're not running the command no need to use
		// modelcmd.Wrap().
		wrappedCommand, command := subnet.NewRemoveCommandForTest(s.api)
		err := coretesting.InitCommand(wrappedCommand, test.args)
		if test.expectErr != "" {
			c.Check(err, gc.ErrorMatches, test.expectErr)
		} else {
			c.Check(err, jc.ErrorIsNil)
			c.Check(command.CIDR, gc.Equals, test.expectCIDR)
		}

		// No API calls should be recorded at this stage.
		s.api.CheckCallNames(c)
	}
}
Пример #2
0
func (s *RemoveSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetFeatureFlags(feature.PostNetCLIMVP)
	s.BaseSubnetSuite.SetUpTest(c)
	s.command, _ = subnet.NewRemoveCommandForTest(s.api)
	c.Assert(s.command, gc.NotNil)
}