Beispiel #1
0
func TestFromSlice(t *testing.T) {
	Convey("Given I have a context", t, func() {
		context := rivers.NewContext()

		Convey("And I have a slice producer", func() {
			numbers := []int{1, 2, 3}
			producer := producers.FromSlice(numbers)

			Convey("When I produce data", func() {
				producer.Attach(context)
				readable := producer.Produce()

				Convey("Then I can read the produced data from the stream", func() {
					So(readable.ReadAll(), ShouldResemble, []stream.T{1, 2, 3})
				})
			})
		})

		Convey("And I have a data producer", func() {
			producer := producers.FromData(1, 2, 3)

			Convey("When I produce data", func() {
				producer.Attach(context)
				readable := producer.Produce()

				Convey("Then I can read the produced data from the stream", func() {
					So(readable.ReadAll(), ShouldResemble, []stream.T{1, 2, 3})
				})
			})
		})
	})
}
Beispiel #2
0
func FromSlice(slice stream.T) *Pipeline {
	return From(producers.FromSlice(slice))
}