Solves #11579.
Signed-off-by: bobby abbott <ttobbaybbob@gmail.com>
| ... | ... |
@@ -3,12 +3,24 @@ package engine |
| 3 | 3 |
import ( |
| 4 | 4 |
"bytes" |
| 5 | 5 |
"encoding/json" |
| 6 |
+ "math/rand" |
|
| 6 | 7 |
"testing" |
| 7 | 8 |
"time" |
| 8 |
- |
|
| 9 |
- "github.com/docker/docker/pkg/testutils" |
|
| 10 | 9 |
) |
| 11 | 10 |
|
| 11 |
+const chars = "abcdefghijklmnopqrstuvwxyz" + |
|
| 12 |
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + |
|
| 13 |
+ "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` "
|
|
| 14 |
+ |
|
| 15 |
+// RandomString returns random string of specified length |
|
| 16 |
+func RandomString(length int) string {
|
|
| 17 |
+ res := make([]byte, length) |
|
| 18 |
+ for i := 0; i < length; i++ {
|
|
| 19 |
+ res[i] = chars[rand.Intn(len(chars))] |
|
| 20 |
+ } |
|
| 21 |
+ return string(res) |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 12 | 24 |
func TestEnvLenZero(t *testing.T) {
|
| 13 | 25 |
env := &Env{}
|
| 14 | 26 |
if env.Len() != 0 {
|
| ... | ... |
@@ -185,7 +197,7 @@ func TestMultiMap(t *testing.T) {
|
| 185 | 185 |
func testMap(l int) [][2]string {
|
| 186 | 186 |
res := make([][2]string, l) |
| 187 | 187 |
for i := 0; i < l; i++ {
|
| 188 |
- t := [2]string{testutils.RandomString(5), testutils.RandomString(20)}
|
|
| 188 |
+ t := [2]string{RandomString(5), RandomString(20)}
|
|
| 189 | 189 |
res[i] = t |
| 190 | 190 |
} |
| 191 | 191 |
return res |
| 3 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,37 +0,0 @@ |
| 1 |
-package testutils |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "math/rand" |
|
| 5 |
- "testing" |
|
| 6 |
- "time" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-const chars = "abcdefghijklmnopqrstuvwxyz" + |
|
| 10 |
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + |
|
| 11 |
- "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:` "
|
|
| 12 |
- |
|
| 13 |
-// Timeout calls f and waits for 100ms for it to complete. |
|
| 14 |
-// If it doesn't, it causes the tests to fail. |
|
| 15 |
-// t must be a valid testing context. |
|
| 16 |
-func Timeout(t *testing.T, f func()) {
|
|
| 17 |
- onTimeout := time.After(100 * time.Millisecond) |
|
| 18 |
- onDone := make(chan bool) |
|
| 19 |
- go func() {
|
|
| 20 |
- f() |
|
| 21 |
- close(onDone) |
|
| 22 |
- }() |
|
| 23 |
- select {
|
|
| 24 |
- case <-onTimeout: |
|
| 25 |
- t.Fatalf("timeout")
|
|
| 26 |
- case <-onDone: |
|
| 27 |
- } |
|
| 28 |
-} |
|
| 29 |
- |
|
| 30 |
-// RandomString returns random string of specified length |
|
| 31 |
-func RandomString(length int) string {
|
|
| 32 |
- res := make([]byte, length) |
|
| 33 |
- for i := 0; i < length; i++ {
|
|
| 34 |
- res[i] = chars[rand.Intn(len(chars))] |
|
| 35 |
- } |
|
| 36 |
- return string(res) |
|
| 37 |
-} |