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

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package controller_test
     5  
     6  import (
     7  	"errors"
     8  
     9  	"github.com/juju/juju/api"
    10  	"github.com/juju/juju/network"
    11  	"github.com/juju/names"
    12  )
    13  
    14  type mockAPIConnection struct {
    15  	api.Connection
    16  	info          *api.Info
    17  	opts          api.DialOpts
    18  	addr          string
    19  	apiHostPorts  [][]network.HostPort
    20  	controllerTag names.ModelTag
    21  	username      string
    22  	password      string
    23  }
    24  
    25  func (*mockAPIConnection) Close() error {
    26  	return nil
    27  }
    28  
    29  func (m *mockAPIConnection) Addr() string {
    30  	return m.addr
    31  }
    32  
    33  func (m *mockAPIConnection) APIHostPorts() [][]network.HostPort {
    34  	return m.apiHostPorts
    35  }
    36  
    37  func (m *mockAPIConnection) ControllerTag() (names.ModelTag, error) {
    38  	if m.controllerTag.Id() == "" {
    39  		return m.controllerTag, errors.New("no server tag")
    40  	}
    41  	return m.controllerTag, nil
    42  }
    43  
    44  func (m *mockAPIConnection) SetPassword(username, password string) error {
    45  	m.username = username
    46  	m.password = password
    47  	return nil
    48  }