From edb2afec9f3c0dd5262587d721710e0c508c6e3c Mon Sep 17 00:00:00 2001 From: bobby abbott Date: Sun, 22 Mar 2015 22:31:46 -0700 Subject: [PATCH] Refactors pkg/testutils Solves #11579. Signed-off-by: bobby abbott --- testutils/README.md | 2 -- testutils/utils.go | 37 ------------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 testutils/README.md delete mode 100644 testutils/utils.go diff --git a/testutils/README.md b/testutils/README.md deleted file mode 100644 index a208a90..0000000 --- a/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/testutils/utils.go b/testutils/utils.go deleted file mode 100644 index 9c664ff..0000000 --- a/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) -}