mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.
Remove these imports in preparation of migrating our code to become an
actual go module.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
37 lines
890 B
Go
37 lines
890 B
Go
package restartmanager
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/docker/docker/api/types/container"
|
|
)
|
|
|
|
func TestRestartManagerTimeout(t *testing.T) {
|
|
rm := New(container.RestartPolicy{Name: "always"}, 0)
|
|
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)
|
|
rm.timeout = 5 * time.Second
|
|
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)
|
|
}
|
|
}
|