1
// Copyright 2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
7
"github.com/juju/errors"
9
"github.com/juju/juju/constraints"
10
"github.com/juju/juju/environs/config"
11
"github.com/juju/juju/instance"
12
"github.com/juju/juju/state"
13
"github.com/juju/juju/storage"
16
type MockPolicy struct {
17
GetPrechecker func() (state.Prechecker, error)
18
GetConfigValidator func() (config.Validator, error)
19
GetConstraintsValidator func() (constraints.Validator, error)
20
GetInstanceDistributor func() (instance.Distributor, error)
21
GetStorageProviderRegistry func() (storage.ProviderRegistry, error)
24
func (p *MockPolicy) Prechecker() (state.Prechecker, error) {
25
if p.GetPrechecker != nil {
26
return p.GetPrechecker()
28
return nil, errors.NotImplementedf("Prechecker")
31
func (p *MockPolicy) ConfigValidator() (config.Validator, error) {
32
if p.GetConfigValidator != nil {
33
return p.GetConfigValidator()
35
return nil, errors.NotImplementedf("ConfigValidator")
38
func (p *MockPolicy) ConstraintsValidator() (constraints.Validator, error) {
39
if p.GetConstraintsValidator != nil {
40
return p.GetConstraintsValidator()
42
return nil, errors.NotImplementedf("ConstraintsValidator")
45
func (p *MockPolicy) InstanceDistributor() (instance.Distributor, error) {
46
if p.GetInstanceDistributor != nil {
47
return p.GetInstanceDistributor()
49
return nil, errors.NotImplementedf("InstanceDistributor")
52
func (p *MockPolicy) StorageProviderRegistry() (storage.ProviderRegistry, error) {
53
if p.GetStorageProviderRegistry != nil {
54
return p.GetStorageProviderRegistry()
56
return nil, errors.NotImplementedf("StorageProviderRegistry")