github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/cmd/juju/space/update_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package space_test
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	gc "gopkg.in/check.v1"
     9  
    10  	"github.com/juju/juju/cmd/juju/space"
    11  	"github.com/juju/juju/feature"
    12  )
    13  
    14  type UpdateSuite struct {
    15  	BaseSpaceSuite
    16  }
    17  
    18  var _ = gc.Suite(&UpdateSuite{})
    19  
    20  func (s *UpdateSuite) SetUpTest(c *gc.C) {
    21  	s.BaseSuite.SetFeatureFlags(feature.PostNetCLIMVP)
    22  	s.BaseSpaceSuite.SetUpTest(c)
    23  	s.command = space.NewUpdateCommandForTest(s.api)
    24  	c.Assert(s.command, gc.NotNil)
    25  }
    26  
    27  func (s *UpdateSuite) TestRunWithSubnetsSucceeds(c *gc.C) {
    28  	s.AssertRunSucceeds(c,
    29  		`updated space "myspace": changed subnets to 10.1.2.0/24, 4.3.2.0/28\n`,
    30  		"", // no stdout, just stderr
    31  		"myspace", "10.1.2.0/24", "4.3.2.0/28",
    32  	)
    33  
    34  	s.api.CheckCallNames(c, "UpdateSpace", "Close")
    35  	s.api.CheckCall(c,
    36  		0, "UpdateSpace",
    37  		"myspace", s.Strings("10.1.2.0/24", "4.3.2.0/28"),
    38  	)
    39  }
    40  
    41  func (s *UpdateSuite) TestRunWhenSpacesAPIFails(c *gc.C) {
    42  	s.api.SetErrors(errors.New("boom"))
    43  
    44  	s.AssertRunFails(c,
    45  		`cannot update space "foo": boom`,
    46  		"foo", "10.1.2.0/24",
    47  	)
    48  
    49  	s.api.CheckCallNames(c, "UpdateSpace", "Close")
    50  	s.api.CheckCall(c, 0, "UpdateSpace", "foo", s.Strings("10.1.2.0/24"))
    51  }