Description:
provider/azure: ensure tests work correctly
Some tests I wrote call StartInstance to
check the parameters passed to createInstance.
The tests don't actually verify that it called
that method successfully, and all validation
is done within the method. Updated the tests
to ensure from outside that the method is called.
// Empty distribution group is equivalent to no DistributionGroup
function.
params.DistributionGroup = func() ([]instance.Id, error) {
return nil, nil
}
env.StartInstance(params)
+ c.Assert(called, gc.Equals, 5)
- // If the machine has the JobManagesEnviron job, we should see
stateServer==true.
+ // If the machine has the JobManagesEnviron job, we should see
+ // stateServer==true.
expectStateServer = true
- params.MachineConfig.Jobs =
[]apiparams.MachineJob{apiparams.JobHostUnits, apiparams.JobManageEnviron}
+ params.MachineConfig.Jobs = []apiparams.MachineJob{
+ apiparams.JobHostUnits, apiparams.JobManageEnviron,
+ }
env.StartInstance(params)
+ c.Assert(called, gc.Equals, 6)
}
Reviewers: mp+214147_ code.launchpad. net,
Message:
Please take a look.
Description:
provider/azure: ensure tests work correctly
Some tests I wrote call StartInstance to
check the parameters passed to createInstance.
The tests don't actually verify that it called
that method successfully, and all validation
is done within the method. Updated the tests
to ensure from outside that the method is called.
https:/ /code.launchpad .net/~axwalk/ juju-core/ azure-test- ensure- called/ +merge/ 214147
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/84290044/
Affected files (+26, -6 lines): azure/environ_ test.go
A [revision details]
M provider/
Index: [revision details] 20140404003547- v7dzlndz9bq9h4q d
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: provider/ azure/environ_ test.go azure/environ_ test.go' azure/environ_ test.go 2014-04-03 18:04:56 +0000 azure/environ_ test.go 2014-04-04 01:54:24 +0000 StartInstancePa rams AssertUploadFak eToolsVersions( c, env.storage, V120p.. .) MachineConfig = environs. NewMachineConfi g("1", "yanonce", nil, AssertUploadFak eToolsVersions( V120p.. ., MachineConfig = environs. NewMachineConfi g(
=== modified file 'provider/
--- provider/
+++ provider/
@@ -1429,44 +1429,62 @@
Tag: "machine-1",
}
var params environs.
- params.Tools = envtesting.
envtesting.
- params.
nil, stateInfo, apiInfo)
+ params.Tools = envtesting.
+ c, env.storage, envtesting.
+ )
+ params.
+ "1", "yanonce", nil, nil, stateInfo, apiInfo,
+ )
// Start out with availability sets disabled. ecfg.attrs[ "availability- sets-enabled" ] = false
env.
var expectServiceName string (&createInstanc e, func(env *azureEnviron, azure ManagementAPI, role *gwacl.Role, serviceName string, stateServer serviceName, gc.Equals, expectServiceName) stateServer, gc.Equals, expectStateServer) StartInstance( params)
var expectStateServer bool
+ var called int
s.PatchValue
*gwacl.
bool) (instance.Instance, error) {
c.Assert(
c.Assert(
+ called++
return nil, nil
})
env.
+ c.Assert(called, gc.Equals, 1)
- // DistributionGroup won't have an effect if sets-enabled= false. sets-enabled= false. eName = "" DistributionGro up = func() ([]instance.Id, error) { Id{instance. Id(env. getEnvPrefix( ) Id(env. getEnvPrefix( ) + "whatever-role0"), StartInstance( params)
availability-
+ // DistributionGroup won't have an effect if
+ // availability-
expectServic
params.
- return []instance.
+ "whatever-role0")}, nil
+ return []instance.Id{
+ instance.
+ }, nil
}
env.
+ c.Assert(called, gc.Equals, 2)
env. ecfg.attrs[ "availability- sets-enabled" ] = true eName = "juju-testenv- whatever" StartInstance( params)
expectServic
env.
+ c.Assert(called, gc.Equals, 3)
expectServic eName = "" DistributionGro up = nil StartInstance( params)
params.
env.
+ c.Assert(called, gc.Equals, 4)
// Empty distribution group is equivalent to no DistributionGroup DistributionGro up = func() ([]instance.Id, error) { StartInstance( params)
function.
params.
return nil, nil
}
env.
+ c.Assert(called, gc.Equals, 5)
- // If the machine has the JobManagesEnviron job, we should see erver = true MachineConfig. Jobs = MachineJob{ apiparams. JobHostUnits, apiparams. JobManageEnviro n} MachineConfig. Jobs = []apiparams. MachineJob{ JobHostUnits, apiparams. JobManageEnviro n, StartInstance( params)
stateServer==true.
+ // If the machine has the JobManagesEnviron job, we should see
+ // stateServer==true.
expectStateS
- params.
[]apiparams.
+ params.
+ apiparams.
+ }
env.
+ c.Assert(called, gc.Equals, 6)
}