github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/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.newCommand = space.NewUpdateCommand
    24  }
    25  
    26  func (s *UpdateSuite) TestRunWithSubnetsSucceeds(c *gc.C) {
    27  	s.AssertRunSucceeds(c,
    28  		`updated space "myspace": changed subnets to 10.1.2.0/24, 4.3.2.0/28\n`,
    29  		"", // no stdout, just stderr
    30  		"myspace", "10.1.2.0/24", "4.3.2.0/28",
    31  	)
    32  
    33  	s.api.CheckCallNames(c, "UpdateSpace", "Close")
    34  	s.api.CheckCall(c,
    35  		0, "UpdateSpace",
    36  		"myspace", s.Strings("10.1.2.0/24", "4.3.2.0/28"),
    37  	)
    38  }
    39  
    40  func (s *UpdateSuite) TestRunWhenSpacesAPIFails(c *gc.C) {
    41  	s.api.SetErrors(errors.New("boom"))
    42  
    43  	s.AssertRunFails(c,
    44  		`cannot update space "foo": boom`,
    45  		"foo", "10.1.2.0/24",
    46  	)
    47  
    48  	s.api.CheckCallNames(c, "UpdateSpace", "Close")
    49  	s.api.CheckCall(c, 0, "UpdateSpace", "foo", s.Strings("10.1.2.0/24"))
    50  }