add session test for closing with errors

This commit is contained in:
Lucas Clemente 2016-04-26 16:49:11 +02:00
parent df08f109e7
commit 43a16a8fce

View file

@ -182,5 +182,20 @@ var _ = Describe("Session", func() {
time.Sleep(1 * time.Millisecond)
Expect(runtime.NumGoroutine()).To(Equal(nGoRoutinesBefore))
})
It("closes streams with proper error", func() {
testErr := errors.New("test error")
s, err := session.NewStream(5)
Expect(err).NotTo(HaveOccurred())
session.Close(testErr)
time.Sleep(1 * time.Millisecond)
Expect(runtime.NumGoroutine()).To(Equal(nGoRoutinesBefore))
n, err := s.Read([]byte{0})
Expect(n).To(BeZero())
Expect(err).To(Equal(testErr))
n, err = s.Write([]byte{0})
Expect(n).To(BeZero())
Expect(err).To(Equal(testErr))
})
})
})