Commit d46e133f authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

mime/multipart: add Writer data race test

Camlistore uses this pattern to do streaming writes, as do
others I imagine, and it was broken by the lazy boundary
change.

LGTM=dvyukov, ruiu
R=ruiu, dvyukov
CC=golang-codereviews, mathieu.lonjaret
https://golang.org/cl/116690043
parent dab671b6
...@@ -111,3 +111,15 @@ func TestWriterSetBoundary(t *testing.T) { ...@@ -111,3 +111,15 @@ func TestWriterSetBoundary(t *testing.T) {
t.Errorf("expected my-separator in output. got: %q", got) t.Errorf("expected my-separator in output. got: %q", got)
} }
} }
func TestWriterBoundaryGoroutines(t *testing.T) {
// Verify there's no data race accessing any lazy boundary if it's used by
// different goroutines. This was previously broken by
// https://codereview.appspot.com/95760043/ and reverted in
// https://codereview.appspot.com/117600043/
w := NewWriter(ioutil.Discard)
go func() {
w.CreateFormField("foo")
}()
w.Boundary()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment