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

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/state/state_leader_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:
9
9
        "github.com/juju/errors"
10
10
        jujutesting "github.com/juju/testing"
11
11
        jc "github.com/juju/testing/checkers"
12
 
        "github.com/juju/utils/clock"
13
12
        gc "gopkg.in/check.v1"
14
13
        "gopkg.in/mgo.v2/txn"
15
14
 
16
15
        "github.com/juju/juju/core/leadership"
17
 
        "github.com/juju/juju/state"
18
16
        coretesting "github.com/juju/juju/testing"
19
17
)
20
18
 
27
25
 
28
26
var _ = gc.Suite(&LeadershipSuite{})
29
27
 
30
 
func (s *LeadershipSuite) SetUpSuite(c *gc.C) {
31
 
        s.ConnSuite.SetUpSuite(c)
32
 
        s.PatchValue(&state.GetClock, func() clock.Clock {
33
 
                return s.clock
34
 
        })
35
 
}
36
 
 
37
28
func (s *LeadershipSuite) SetUpTest(c *gc.C) {
 
29
        s.ConnSuite.SetUpTest(c)
38
30
        s.clock = jujutesting.NewClock(time.Now())
39
 
        s.ConnSuite.SetUpTest(c)
 
31
        err := s.State.SetClockForTesting(s.clock)
 
32
        c.Assert(err, jc.ErrorIsNil)
40
33
        s.checker = s.State.LeadershipChecker()
41
34
        s.claimer = s.State.LeadershipClaimer()
42
35
}
137
130
 
138
131
func (s *LeadershipSuite) expire(c *gc.C, applicationname string) {
139
132
        s.clock.Advance(time.Hour)
 
133
        s.Session.Fsync(false)
140
134
        select {
141
135
        case err := <-s.expiryChan(applicationname):
142
136
                c.Assert(err, jc.ErrorIsNil)