From 10b847be8e478bc96cced44ea5bb19d22b5495b1 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Fri, 12 Aug 2016 20:22:05 +0200 Subject: [PATCH] fix flaky session test fixes #277 --- session_test.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/session_test.go b/session_test.go index a80849b6..4fdacac9 100644 --- a/session_test.go +++ b/session_test.go @@ -591,18 +591,17 @@ var _ = Describe("Session", func() { Expect(err).NotTo(HaveOccurred()) s2, err := session.GetOrOpenStream(7) Expect(err).NotTo(HaveOccurred()) - go func() { - time.Sleep(time.Millisecond) - session.run() - }() - go func() { - _, err2 := s1.Write([]byte("foobar1")) - Expect(err2).NotTo(HaveOccurred()) - }() - _, err = s2.Write([]byte("foobar2")) - Expect(err).NotTo(HaveOccurred()) - time.Sleep(10 * time.Millisecond) - Expect(conn.written).To(HaveLen(1)) + + // Put data directly into the streams + s1.(*stream).dataForWriting = []byte("foobar1") + s2.(*stream).dataForWriting = []byte("foobar2") + + session.scheduleSending() + go session.run() + + Eventually(func() [][]byte { return conn.written }).Should(HaveLen(1)) + Expect(conn.written[0]).To(ContainSubstring("foobar1")) + Expect(conn.written[0]).To(ContainSubstring("foobar2")) }) It("sends out two big frames in two packets", func() {