Skip to content

Commit

Permalink
enhc: removing sleep() from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfolkins committed Jan 21, 2015
1 parent 7c25a2d commit 511b36b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 2 additions & 3 deletions action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ func TestActionWhenTimeServed(t *testing.T) {
t.Errorf("whenTimeServedCounter should be 0 instead", whenTimeServedCounter)
}

dur := time.Duration(time.Second * 1)

time.Sleep(dur)
dur := time.Now().Add(-time.Hour * 1)
a.jails[rn].releaseBy = dur

for _, j := range a.jails {
a.timeServed(j)
Expand Down
4 changes: 4 additions & 0 deletions director.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,7 @@ func (d *Director) timeToLive(an string) time.Time {
func (d *Director) keepAlive(an string) {
d.actors[an].Value.(*Actor).rebaseAll()
}

func (d *Director) actor(an string) *Actor {
return d.actors[an].Value.(*Actor)
}
8 changes: 7 additions & 1 deletion director_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,22 @@ func TestDirectorlMaintenance(t *testing.T) {

// MOCK STATE CHANGE
// Remove 10 minutes from the world
a := d.actors[an].Value.(*Actor)
// get actor
a := d.actor(an)
// set time to be one hour ago
dur := time.Now().Add(-time.Hour * 1)

// change time.Time of infraction and jail
a.jails[r1n].releaseBy = dur
a.infractions[r2n].expireBy = dur

// perform maintenance
d.lMaintenance()

// change time to live
a.ttl = dur

// perform maintenance
d.lMaintenance()

b = d.lInfractionExists(an, r2n)
Expand Down

0 comments on commit 511b36b

Please sign in to comment.