}
						})

						It("does not error", func() {
							Expect(buildNumber).To(Equal(1))
							Expect(buildNumberToStream).To(Equal(1))
							Expect(sErr).NotTo(HaveOccurred())
						})

						It("blocks on read operations", func() {
							done := make(chan bool)
							go func(c chan<- bool) {
								defer GinkgoRecover()
								content := []byte{}
								for {
									nextBytes, done := streamer.Next()
									content = append(content, nextBytes...)
									if done {
										break
									}
								}
								Expect(content).To(Equal([]byte("output from builda linemore\nlines")))
								c <- true
							}(done)

							_, err := outputDest.Write([]byte("a line"))
							Expect(err).NotTo(HaveOccurred())
							_, err = outputDest.Write([]byte("more\nlines"))
							Expect(err).NotTo(HaveOccurred())
							Expect(outputDest.Close()).To(Succeed())
							exitStatusChan <- 0
		reader, writer = io.Pipe()
		br = &chunkedio.ChunkedReader{
			Output:      reader,
			DoneWriting: func() bool { return done },
			Buffer:      make([]byte, 1024),
		}
	})

	Context("when the writer is already done and no output has been written", func() {
		BeforeEach(func() {
			Expect(writer.Close()).To(Succeed())
			done = true
		})

		It("returns empty slice and true", func() {
			out, finished := br.Next()
			Expect(out).To(BeEmpty())
			Expect(finished).To(BeTrue())
		})
	})

	Context("when there is a small amount of output and the writer is done", func() {
		var testFinished chan bool

		BeforeEach(func() {
			testFinished = make(chan bool)

			go func() {
				defer GinkgoRecover()
				_, err := writer.Write([]byte("Hello world!"))
				Expect(err).NotTo(HaveOccurred())