12
12
"launchpad.net/juju-core/cmd"
13
13
"launchpad.net/juju-core/environs"
14
14
"launchpad.net/juju-core/environs/sync"
15
envtesting "launchpad.net/juju-core/environs/testing"
16
15
"launchpad.net/juju-core/provider/dummy"
17
16
coretesting "launchpad.net/juju-core/testing"
17
jc "launchpad.net/juju-core/testing/checkers"
20
20
type syncToolsSuite struct {
75
74
description: "environment as only argument",
76
75
args: []string{"-e", "test-target"},
77
sctx: &sync.SyncContext{
78
EnvName: "test-target",
76
sctx: &sync.SyncContext{},
82
79
description: "specifying also the synchronization source",
83
80
args: []string{"-e", "test-target", "--source", "/foo/bar"},
84
81
sctx: &sync.SyncContext{
85
EnvName: "test-target",
90
86
description: "synchronize all version including development",
91
87
args: []string{"-e", "test-target", "--all", "--dev"},
92
88
sctx: &sync.SyncContext{
93
EnvName: "test-target",
107
101
description: "just make a dry run",
108
102
args: []string{"-e", "test-target", "--dry-run"},
109
103
sctx: &sync.SyncContext{
110
EnvName: "test-target",
109
func (s *syncToolsSuite) Reset(c *gc.C) {
116
114
func (s *syncToolsSuite) TestSyncToolsCommand(c *gc.C) {
117
for _, test := range tests {
118
c.Log(test.description)
119
called := make(chan struct{}, 1)
115
for i, test := range tests {
116
c.Logf("test %d: %s", i, test.description)
120
118
syncTools = func(sctx *sync.SyncContext) error {
121
c.Assert(sctx.EnvName, gc.Equals, test.sctx.EnvName)
119
env := sctx.Target.(environs.Environ)
120
c.Assert(env.Name(), gc.Equals, s.targetEnv.Name())
122
121
c.Assert(sctx.AllVersions, gc.Equals, test.sctx.AllVersions)
123
122
c.Assert(sctx.DryRun, gc.Equals, test.sctx.DryRun)
124
123
c.Assert(sctx.PublicBucket, gc.Equals, test.sctx.PublicBucket)
125
124
c.Assert(sctx.Dev, gc.Equals, test.sctx.Dev)
126
125
c.Assert(sctx.Source, gc.Equals, test.sctx.Source)
126
s.targetEnv.Storage() // This will panic if the environment is not prepared.
130
130
ctx, err := runSyncToolsCommand(c, test.args...)
131
131
c.Assert(err, gc.IsNil)
132
132
c.Assert(ctx, gc.NotNil)
133
c.Assert(wait(called), gc.IsNil)
133
c.Assert(called, jc.IsTrue)