github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/featuretests/block_test.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package featuretests
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	jc "github.com/juju/testing/checkers"
     9  	gc "gopkg.in/check.v1"
    10  
    11  	"github.com/juju/juju/api/block"
    12  	jujutesting "github.com/juju/juju/juju/testing"
    13  	"github.com/juju/juju/state"
    14  )
    15  
    16  type blockSuite struct {
    17  	jujutesting.JujuConnSuite
    18  	blockClient *block.Client
    19  }
    20  
    21  func (s *blockSuite) SetUpTest(c *gc.C) {
    22  	s.JujuConnSuite.SetUpTest(c)
    23  	s.blockClient = block.NewClient(s.APIState)
    24  	c.Assert(s.blockClient, gc.NotNil)
    25  }
    26  
    27  func (s *blockSuite) TearDownTest(c *gc.C) {
    28  	s.blockClient.ClientFacade.Close()
    29  	s.JujuConnSuite.TearDownTest(c)
    30  }
    31  
    32  func (s *blockSuite) TestBlockFacadeCall(c *gc.C) {
    33  	found, err := s.blockClient.List()
    34  	c.Assert(err, jc.ErrorIsNil)
    35  	c.Assert(found, gc.HasLen, 0)
    36  }
    37  
    38  func (s *blockSuite) TestBlockFacadeCallGettingErrors(c *gc.C) {
    39  	err := s.blockClient.SwitchBlockOff(state.DestroyBlock.String())
    40  	c.Assert(errors.Cause(err), gc.ErrorMatches, `.*is already OFF.*`)
    41  }