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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/worker/deployer/deployer_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:
79
79
        // Cause a unit to become Dying, and check no change.
80
80
        now := time.Now()
81
81
        sInfo := status.StatusInfo{
82
 
                Status:  status.StatusIdle,
 
82
                Status:  status.Idle,
83
83
                Message: "",
84
84
                Since:   &now,
85
85
        }
108
108
        c.Assert(u1.Life(), gc.Equals, state.Dying)
109
109
}
110
110
 
 
111
func (s *deployerSuite) TestInitialStatusMessages(c *gc.C) {
 
112
        svc := s.AddTestingService(c, "wordpress", s.AddTestingCharm(c, "wordpress"))
 
113
        u0, err := svc.AddUnit()
 
114
        c.Assert(err, jc.ErrorIsNil)
 
115
 
 
116
        dep, _ := s.makeDeployerAndContext(c)
 
117
        defer stop(c, dep)
 
118
        err = u0.AssignToMachine(s.machine)
 
119
        c.Assert(err, jc.ErrorIsNil)
 
120
        s.waitFor(c, unitStatus(u0, status.StatusInfo{
 
121
                Status:  status.Waiting,
 
122
                Message: "installing agent",
 
123
        }))
 
124
}
 
125
 
111
126
func (s *deployerSuite) TestRemoveNonAlivePrincipals(c *gc.C) {
112
127
        // Create a service, and a couple of units.
113
128
        svc := s.AddTestingService(c, "wordpress", s.AddTestingCharm(c, "wordpress"))
128
143
        // would happen if it were possible to have a dying unit in this situation.
129
144
        now := time.Now()
130
145
        sInfo := status.StatusInfo{
131
 
                Status:  status.StatusIdle,
 
146
                Status:  status.Idle,
132
147
                Message: "",
133
148
                Since:   &now,
134
149
        }
265
280
        }
266
281
}
267
282
 
 
283
func unitStatus(u *state.Unit, statusInfo status.StatusInfo) func(*gc.C) bool {
 
284
        return func(c *gc.C) bool {
 
285
                sInfo, err := u.Status()
 
286
                c.Assert(err, jc.ErrorIsNil)
 
287
                return sInfo.Status == statusInfo.Status && sInfo.Message == statusInfo.Message
 
288
        }
 
289
}
 
290
 
268
291
func stop(c *gc.C, w worker.Worker) {
269
292
        c.Assert(worker.Stop(w), gc.IsNil)
270
293
}