~dave-cheney/juju-core/069-worker-stater-I

« back to all changes in this revision

Viewing changes to state/relation_test.go

  • Committer: William Reade
  • Author(s): William Reade
  • Date: 2013-01-15 11:37:23 UTC
  • mfrom: (822.1.8 juju-core)
  • Revision ID: fwereade@gmail.com-20130115113723-9yvzpddjcm1uk1dr
uniter: react sanely to Dying required subordinate

see lp:1091866

R=dimitern, rog
CC=
https://codereview.appspot.com/7094045

Show diffs side-by-side

added added

removed removed

Lines of Context:
338
338
        c.Assert(err, IsNil)
339
339
 
340
340
        // Check that no units of the subordinate service exist.
341
 
        assertSubCount := func(expect int) {
 
341
        assertSubCount := func(expect int) []*state.Unit {
342
342
                runits, err := rsvc.AllUnits()
343
343
                c.Assert(err, IsNil)
344
344
                c.Assert(runits, HasLen, expect)
 
345
                return runits
345
346
        }
346
347
        assertSubCount(0)
347
348
 
361
362
        c.Assert(err, IsNil)
362
363
        err = pru.EnterScope()
363
364
        c.Assert(err, IsNil)
 
365
        runits := assertSubCount(1)
 
366
 
 
367
        // Set the subordinate to Dying, and enter scope again; because the scope
 
368
        // is already entered, no error is returned.
 
369
        runit := runits[0]
 
370
        err = runit.EnsureDying()
 
371
        c.Assert(err, IsNil)
 
372
        err = pru.EnterScope()
 
373
        c.Assert(err, IsNil)
 
374
 
 
375
        // Leave scope, then try to enter again with the Dying subordinate.
 
376
        err = pru.LeaveScope()
 
377
        c.Assert(err, IsNil)
 
378
        err = pru.EnterScope()
 
379
        c.Assert(err, Equals, state.ErrCannotEnterScopeYet)
 
380
 
 
381
        // Remove the subordinate, and enter scope again; this should work, and
 
382
        // create a new subordinate.
 
383
        err = runit.EnsureDead()
 
384
        c.Assert(err, IsNil)
 
385
        err = rsvc.RemoveUnit(runit)
 
386
        c.Assert(err, IsNil)
 
387
        assertSubCount(0)
 
388
        err = pru.EnterScope()
 
389
        c.Assert(err, IsNil)
364
390
        assertSubCount(1)
365
391
}
366
392