1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/restartmanager/restartmanager_test.go
Sebastiaan van Stijn 2c31edbbb6
unconvert: remove unnescessary conversions
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:33 +02:00

36 lines
984 B
Go

package restartmanager // import "github.com/docker/docker/restartmanager"
import (
"testing"
"time"
"github.com/docker/docker/api/types/container"
)
func TestRestartManagerTimeout(t *testing.T) {
rm := New(container.RestartPolicy{Name: "always"}, 0).(*restartManager)
var 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 != 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
var duration = 10 * time.Second
_, _, err := rm.ShouldRestart(0, false, duration)
if err != nil {
t.Fatal(err)
}
if rm.timeout != defaultTimeout {
t.Fatalf("restart manager should have a timeout of 100 ms but has %s", rm.timeout)
}
}