Jelajahi Sumber

Fix randomly failing test

Philipp Heckel 3 tahun lalu
induk
melakukan
6ee3349cca
1 mengubah file dengan 1 tambahan dan 1 penghapusan
  1. 1 1
      util/content_type_writer_test.go

+ 1 - 1
util/content_type_writer_test.go

@@ -44,7 +44,7 @@ func TestSniffWriter_WriteUnknownMimeType(t *testing.T) {
 	rr := httptest.NewRecorder()
 	rr := httptest.NewRecorder()
 	sw := NewContentTypeWriter(rr, "")
 	sw := NewContentTypeWriter(rr, "")
 	randomBytes := make([]byte, 199)
 	randomBytes := make([]byte, 199)
-	rand.Read(randomBytes)
+	rand.Read(randomBytes[5:]) // Start at an offset; the test kept failing randomly because it hit random magic strings
 	sw.Write(randomBytes)
 	sw.Write(randomBytes)
 	require.Equal(t, "application/octet-stream", rr.Header().Get("Content-Type"))
 	require.Equal(t, "application/octet-stream", rr.Header().Get("Content-Type"))
 }
 }