]> Cypherpunks repositories - gostls13.git/commitdiff
http: do not depend on map iteration order
authorRuss Cox <rsc@golang.org>
Mon, 17 Oct 2011 18:51:54 +0000 (14:51 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 17 Oct 2011 18:51:54 +0000 (14:51 -0400)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5284050

src/pkg/http/client_test.go

index f22cce50b89717ef02f01210d688376c29521c60..0ad6cd7c2f3246bbca36347c606c269e30c6a230 100644 (file)
@@ -132,7 +132,9 @@ func TestPostFormRequestFormat(t *testing.T) {
        if tr.req.Close {
                t.Error("got Close true, want false")
        }
+       // Depending on map iteration, body can be either of these.
        expectedBody := "foo=bar&foo=bar2&bar=baz"
+       expectedBody1 := "bar=baz&foo=bar&foo=bar2"
        if g, e := tr.req.ContentLength, int64(len(expectedBody)); g != e {
                t.Errorf("got ContentLength %d, want %d", g, e)
        }
@@ -140,8 +142,8 @@ func TestPostFormRequestFormat(t *testing.T) {
        if err != nil {
                t.Fatalf("ReadAll on req.Body: %v", err)
        }
-       if g := string(bodyb); g != expectedBody {
-               t.Errorf("got body %q, want %q", g, expectedBody)
+       if g := string(bodyb); g != expectedBody && g != expectedBody1 {
+               t.Errorf("got body %q, want %q or %q", g, expectedBody, expectedBody1)
        }
 }