~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/apiserver/common/storagecommon/mock_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2015 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package storagecommon_test
 
5
 
 
6
import (
 
7
        "github.com/juju/errors"
 
8
        "github.com/juju/testing"
 
9
        "gopkg.in/juju/names.v2"
 
10
 
 
11
        "github.com/juju/juju/apiserver/common/storagecommon"
 
12
        "github.com/juju/juju/state"
 
13
        "github.com/juju/juju/storage"
 
14
        "github.com/juju/juju/storage/poolmanager"
 
15
)
 
16
 
 
17
type fakeStorage struct {
 
18
        testing.Stub
 
19
        storagecommon.StorageInterface
 
20
        storageInstance        func(names.StorageTag) (state.StorageInstance, error)
 
21
        storageInstanceVolume  func(names.StorageTag) (state.Volume, error)
 
22
        volumeAttachment       func(names.MachineTag, names.VolumeTag) (state.VolumeAttachment, error)
 
23
        blockDevices           func(names.MachineTag) ([]state.BlockDeviceInfo, error)
 
24
        watchVolumeAttachment  func(names.MachineTag, names.VolumeTag) state.NotifyWatcher
 
25
        watchBlockDevices      func(names.MachineTag) state.NotifyWatcher
 
26
        watchStorageAttachment func(names.StorageTag, names.UnitTag) state.NotifyWatcher
 
27
}
 
28
 
 
29
func (s *fakeStorage) StorageInstance(tag names.StorageTag) (state.StorageInstance, error) {
 
30
        s.MethodCall(s, "StorageInstance", tag)
 
31
        return s.storageInstance(tag)
 
32
}
 
33
 
 
34
func (s *fakeStorage) StorageInstanceVolume(tag names.StorageTag) (state.Volume, error) {
 
35
        s.MethodCall(s, "StorageInstanceVolume", tag)
 
36
        return s.storageInstanceVolume(tag)
 
37
}
 
38
 
 
39
func (s *fakeStorage) VolumeAttachment(m names.MachineTag, v names.VolumeTag) (state.VolumeAttachment, error) {
 
40
        s.MethodCall(s, "VolumeAttachment", m, v)
 
41
        return s.volumeAttachment(m, v)
 
42
}
 
43
 
 
44
func (s *fakeStorage) BlockDevices(m names.MachineTag) ([]state.BlockDeviceInfo, error) {
 
45
        s.MethodCall(s, "BlockDevices", m)
 
46
        return s.blockDevices(m)
 
47
}
 
48
 
 
49
func (s *fakeStorage) WatchVolumeAttachment(m names.MachineTag, v names.VolumeTag) state.NotifyWatcher {
 
50
        s.MethodCall(s, "WatchVolumeAttachment", m, v)
 
51
        return s.watchVolumeAttachment(m, v)
 
52
}
 
53
 
 
54
func (s *fakeStorage) WatchBlockDevices(m names.MachineTag) state.NotifyWatcher {
 
55
        s.MethodCall(s, "WatchBlockDevices", m)
 
56
        return s.watchBlockDevices(m)
 
57
}
 
58
 
 
59
func (s *fakeStorage) WatchStorageAttachment(st names.StorageTag, u names.UnitTag) state.NotifyWatcher {
 
60
        s.MethodCall(s, "WatchStorageAttachment", st, u)
 
61
        return s.watchStorageAttachment(st, u)
 
62
}
 
63
 
 
64
type fakeStorageInstance struct {
 
65
        state.StorageInstance
 
66
        tag   names.StorageTag
 
67
        owner names.Tag
 
68
        kind  state.StorageKind
 
69
}
 
70
 
 
71
func (i *fakeStorageInstance) StorageTag() names.StorageTag {
 
72
        return i.tag
 
73
}
 
74
 
 
75
func (i *fakeStorageInstance) Tag() names.Tag {
 
76
        return i.tag
 
77
}
 
78
 
 
79
func (i *fakeStorageInstance) Owner() names.Tag {
 
80
        return i.owner
 
81
}
 
82
 
 
83
func (i *fakeStorageInstance) Kind() state.StorageKind {
 
84
        return i.kind
 
85
}
 
86
 
 
87
type fakeStorageAttachment struct {
 
88
        state.StorageAttachment
 
89
        storageTag names.StorageTag
 
90
}
 
91
 
 
92
func (a *fakeStorageAttachment) StorageInstance() names.StorageTag {
 
93
        return a.storageTag
 
94
}
 
95
 
 
96
type fakeVolume struct {
 
97
        state.Volume
 
98
        tag    names.VolumeTag
 
99
        params *state.VolumeParams
 
100
        info   *state.VolumeInfo
 
101
}
 
102
 
 
103
func (v *fakeVolume) VolumeTag() names.VolumeTag {
 
104
        return v.tag
 
105
}
 
106
 
 
107
func (v *fakeVolume) Tag() names.Tag {
 
108
        return v.tag
 
109
}
 
110
 
 
111
func (v *fakeVolume) Params() (state.VolumeParams, bool) {
 
112
        if v.params == nil {
 
113
                return state.VolumeParams{}, false
 
114
        }
 
115
        return *v.params, true
 
116
}
 
117
 
 
118
func (v *fakeVolume) Info() (state.VolumeInfo, error) {
 
119
        if v.info == nil {
 
120
                return state.VolumeInfo{}, errors.NotProvisionedf("volume %v", v.tag.Id())
 
121
        }
 
122
        return *v.info, nil
 
123
}
 
124
 
 
125
type fakeVolumeAttachment struct {
 
126
        state.VolumeAttachment
 
127
        info *state.VolumeAttachmentInfo
 
128
}
 
129
 
 
130
func (v *fakeVolumeAttachment) Info() (state.VolumeAttachmentInfo, error) {
 
131
        if v.info == nil {
 
132
                return state.VolumeAttachmentInfo{}, errors.NotProvisionedf("volume attachment")
 
133
        }
 
134
        return *v.info, nil
 
135
}
 
136
 
 
137
type fakePoolManager struct {
 
138
        poolmanager.PoolManager
 
139
}
 
140
 
 
141
func (pm *fakePoolManager) Get(name string) (*storage.Config, error) {
 
142
        return nil, errors.NotFoundf("pool")
 
143
}
 
144
 
 
145
type nopSyncStarter struct{}
 
146
 
 
147
func (nopSyncStarter) StartSync() {}