~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/testing/policy.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 2014 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package testing
 
5
 
 
6
import (
 
7
        "github.com/juju/errors"
 
8
 
 
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"
 
14
)
 
15
 
 
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)
 
22
}
 
23
 
 
24
func (p *MockPolicy) Prechecker() (state.Prechecker, error) {
 
25
        if p.GetPrechecker != nil {
 
26
                return p.GetPrechecker()
 
27
        }
 
28
        return nil, errors.NotImplementedf("Prechecker")
 
29
}
 
30
 
 
31
func (p *MockPolicy) ConfigValidator() (config.Validator, error) {
 
32
        if p.GetConfigValidator != nil {
 
33
                return p.GetConfigValidator()
 
34
        }
 
35
        return nil, errors.NotImplementedf("ConfigValidator")
 
36
}
 
37
 
 
38
func (p *MockPolicy) ConstraintsValidator() (constraints.Validator, error) {
 
39
        if p.GetConstraintsValidator != nil {
 
40
                return p.GetConstraintsValidator()
 
41
        }
 
42
        return nil, errors.NotImplementedf("ConstraintsValidator")
 
43
}
 
44
 
 
45
func (p *MockPolicy) InstanceDistributor() (instance.Distributor, error) {
 
46
        if p.GetInstanceDistributor != nil {
 
47
                return p.GetInstanceDistributor()
 
48
        }
 
49
        return nil, errors.NotImplementedf("InstanceDistributor")
 
50
}
 
51
 
 
52
func (p *MockPolicy) StorageProviderRegistry() (storage.ProviderRegistry, error) {
 
53
        if p.GetStorageProviderRegistry != nil {
 
54
                return p.GetStorageProviderRegistry()
 
55
        }
 
56
        return nil, errors.NotImplementedf("StorageProviderRegistry")
 
57
}