mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Optimize the unit test for restartmanager
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
This commit is contained in:
parent
e47ca825d1
commit
0a0bbab81d
2 changed files with 10 additions and 8 deletions
|
@ -9,26 +9,28 @@ import (
|
|||
|
||||
func TestRestartManagerTimeout(t *testing.T) {
|
||||
rm := New(container.RestartPolicy{Name: "always"}, 0).(*restartManager)
|
||||
should, _, err := rm.ShouldRestart(0, false, 1*time.Second)
|
||||
var duration = time.Duration(1 * time.Second)
|
||||
should, _, err := rm.ShouldRestart(0, false, duration)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !should {
|
||||
t.Fatal("container should be restarted")
|
||||
}
|
||||
if rm.timeout != 100*time.Millisecond {
|
||||
t.Fatalf("restart manager should have a timeout of 100ms but has %s", rm.timeout)
|
||||
if rm.timeout != defaultTimeout {
|
||||
t.Fatalf("restart manager should have a timeout of 100 ms but has %s", rm.timeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestartManagerTimeoutReset(t *testing.T) {
|
||||
rm := New(container.RestartPolicy{Name: "always"}, 0).(*restartManager)
|
||||
rm.timeout = 5 * time.Second
|
||||
_, _, err := rm.ShouldRestart(0, false, 10*time.Second)
|
||||
var duration = time.Duration(10 * time.Second)
|
||||
_, _, err := rm.ShouldRestart(0, false, duration)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rm.timeout != 100*time.Millisecond {
|
||||
t.Fatalf("restart manager should have a timeout of 100ms but has %s", rm.timeout)
|
||||
if rm.timeout != defaultTimeout {
|
||||
t.Fatalf("restart manager should have a timeout of 100 ms but has %s", rm.timeout)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue