~juju-qa/ubuntu/yakkety/juju/juju-1.25.8

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/juju/mock_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-12-02 17:28:37 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161202172837-jkrbdlyjcxtrii2n
Initial commit of 1.25.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package juju_test
 
2
 
 
3
import (
 
4
        "github.com/juju/errors"
 
5
        "github.com/juju/names"
 
6
 
 
7
        "github.com/juju/juju/api"
 
8
        "github.com/juju/juju/network"
 
9
)
 
10
 
 
11
type mockAPIState struct {
 
12
        api.Connection
 
13
        close func(api.Connection) error
 
14
 
 
15
        addr         string
 
16
        apiHostPorts [][]network.HostPort
 
17
        environTag   string
 
18
}
 
19
 
 
20
func (s *mockAPIState) Close() error {
 
21
        if s.close != nil {
 
22
                return s.close(s)
 
23
        }
 
24
        return nil
 
25
}
 
26
 
 
27
func (s *mockAPIState) Addr() string {
 
28
        return s.addr
 
29
}
 
30
 
 
31
func (s *mockAPIState) APIHostPorts() [][]network.HostPort {
 
32
        return s.apiHostPorts
 
33
}
 
34
 
 
35
func (s *mockAPIState) EnvironTag() (names.EnvironTag, error) {
 
36
        return names.ParseEnvironTag(s.environTag)
 
37
}
 
38
 
 
39
func (s *mockAPIState) ServerTag() (names.EnvironTag, error) {
 
40
        return names.EnvironTag{}, errors.NotImplementedf("ServerTag")
 
41
}
 
42
 
 
43
func panicAPIOpen(apiInfo *api.Info, opts api.DialOpts) (api.Connection, error) {
 
44
        panic("api.Open called unexpectedly")
 
45
}