~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/environ/fixture_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
}
39
39
 
40
40
type runContext struct {
41
 
        mu      sync.Mutex
42
 
        stub    testing.Stub
43
 
        cloud   environs.CloudSpec
44
 
        config  map[string]interface{}
45
 
        watcher *notifyWatcher
 
41
        mu          sync.Mutex
 
42
        stub        testing.Stub
 
43
        cloud       environs.CloudSpec
 
44
        config      map[string]interface{}
 
45
        watcher     *notifyWatcher
 
46
        credWatcher *notifyWatcher
46
47
}
47
48
 
48
49
// SetConfig updates the configuration returned by ModelConfig.
74
75
        return config.New(config.NoDefaults, context.config)
75
76
}
76
77
 
77
 
// KillNotify kills the watcher returned from WatchForModelConfigChanges with
 
78
// KillModelConfigNotify kills the watcher returned from WatchForModelConfigChanges with
78
79
// the error configured in the enclosing fixture.
79
 
func (context *runContext) KillNotify() {
 
80
func (context *runContext) KillModelConfigNotify() {
80
81
        context.watcher.Kill()
81
82
}
82
83
 
83
 
// SendNotify sends a value on the channel used by WatchForModelConfigChanges
 
84
// SendModelConfigNotify sends a value on the channel used by WatchForModelConfigChanges
84
85
// results.
85
 
func (context *runContext) SendNotify() {
 
86
func (context *runContext) SendModelConfigNotify() {
86
87
        context.watcher.changes <- struct{}{}
87
88
}
88
89
 
89
 
// CloseNotify closes the channel used by WatchForModelConfigChanges results.
90
 
func (context *runContext) CloseNotify() {
 
90
// CloseModelConfigNotify closes the channel used by WatchForModelConfigChanges results.
 
91
func (context *runContext) CloseModelConfigNotify() {
91
92
        close(context.watcher.changes)
92
93
}
93
94
 
102
103
        return context.watcher, nil
103
104
}
104
105
 
 
106
// KillCredentialNotify kills the watcher returned from WatchCredentialChanges with
 
107
// the error configured in the enclosing fixture.
 
108
func (context *runContext) KillCredentialNotify() {
 
109
        context.credWatcher.Kill()
 
110
}
 
111
 
 
112
// SendCredentialNotify sends a value on the channel used by WatchCredentialChanges
 
113
// results.
 
114
func (context *runContext) SendCredentialNotify() {
 
115
        context.credWatcher.changes <- struct{}{}
 
116
}
 
117
 
 
118
// CloseCredentialNotify closes the channel used by WatchCredentialChanges results.
 
119
func (context *runContext) CloseCredentialNotify() {
 
120
        close(context.credWatcher.changes)
 
121
}
 
122
 
 
123
// WatchCredential is part of the environ.ConfigObserver interface.
 
124
func (context *runContext) WatchCredential(cred names.CloudCredentialTag) (watcher.NotifyWatcher, error) {
 
125
        context.mu.Lock()
 
126
        defer context.mu.Unlock()
 
127
        context.stub.AddCall("WatchCredential")
 
128
        if err := context.stub.NextErr(); err != nil {
 
129
                return nil, err
 
130
        }
 
131
        return context.watcher, nil
 
132
}
 
133
 
105
134
func (context *runContext) CheckCallNames(c *gc.C, names ...string) {
106
135
        context.mu.Lock()
107
136
        defer context.mu.Unlock()