github.com/cloud-green/juju@v0.0.0-20151002100041-a00291338d3d/cmd/juju/block/export_test.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package block
     5  
     6  import "github.com/juju/juju/apiserver/params"
     7  
     8  var (
     9  	BlockClient   = &getBlockClientAPI
    10  	UnblockClient = &getUnblockClientAPI
    11  	ListClient    = &getBlockListAPI
    12  )
    13  
    14  type MockBlockClient struct {
    15  	BlockType string
    16  	Msg       string
    17  }
    18  
    19  func (c *MockBlockClient) Close() error {
    20  	return nil
    21  }
    22  
    23  func (c *MockBlockClient) SwitchBlockOn(blockType, msg string) error {
    24  	c.BlockType = blockType
    25  	c.Msg = msg
    26  	return nil
    27  }
    28  
    29  func (c *MockBlockClient) SwitchBlockOff(blockType string) error {
    30  	c.BlockType = blockType
    31  	c.Msg = ""
    32  	return nil
    33  }
    34  
    35  func (c *MockBlockClient) List() ([]params.Block, error) {
    36  	if c.BlockType == "" {
    37  		return []params.Block{}, nil
    38  	}
    39  
    40  	return []params.Block{
    41  		params.Block{
    42  			Type:    c.BlockType,
    43  			Message: c.Msg,
    44  		},
    45  	}, nil
    46  }