diff --git a/engine/env_test.go b/engine/env_test.go index 2ed99d0fea..5182783bb3 100644 --- a/engine/env_test.go +++ b/engine/env_test.go @@ -3,12 +3,24 @@ package engine import ( "bytes" "encoding/json" + "math/rand" "testing" "time" - - "github.com/docker/docker/pkg/testutils" ) +const chars = "abcdefghijklmnopqrstuvwxyz" + + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` " + +// RandomString returns random string of specified length +func RandomString(length int) string { + res := make([]byte, length) + for i := 0; i < length; i++ { + res[i] = chars[rand.Intn(len(chars))] + } + return string(res) +} + func TestEnvLenZero(t *testing.T) { env := &Env{} if env.Len() != 0 { @@ -185,7 +197,7 @@ func TestMultiMap(t *testing.T) { func testMap(l int) [][2]string { res := make([][2]string, l) for i := 0; i < l; i++ { - t := [2]string{testutils.RandomString(5), testutils.RandomString(20)} + t := [2]string{RandomString(5), RandomString(20)} res[i] = t } return res diff --git a/pkg/testutils/README.md b/pkg/testutils/README.md deleted file mode 100644 index a208a90e68..0000000000 --- a/pkg/testutils/README.md +++ /dev/null @@ -1,2 +0,0 @@ -`testutils` is a collection of utility functions to facilitate the writing -of tests. It is used in various places by the Docker test suite. diff --git a/pkg/testutils/utils.go b/pkg/testutils/utils.go deleted file mode 100644 index 9c664ff253..0000000000 --- a/pkg/testutils/utils.go +++ /dev/null @@ -1,37 +0,0 @@ -package testutils - -import ( - "math/rand" - "testing" - "time" -) - -const chars = "abcdefghijklmnopqrstuvwxyz" + - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + - "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` " - -// Timeout calls f and waits for 100ms for it to complete. -// If it doesn't, it causes the tests to fail. -// t must be a valid testing context. -func Timeout(t *testing.T, f func()) { - onTimeout := time.After(100 * time.Millisecond) - onDone := make(chan bool) - go func() { - f() - close(onDone) - }() - select { - case <-onTimeout: - t.Fatalf("timeout") - case <-onDone: - } -} - -// RandomString returns random string of specified length -func RandomString(length int) string { - res := make([]byte, length) - for i := 0; i < length; i++ { - res[i] = chars[rand.Intn(len(chars))] - } - return string(res) -}