func (s *StreamReaderSuite) TestScanEventData(c *C) {
	streamName := "SomeStream"
	ne := 1
	es := mock.CreateTestEvents(ne, streamName, server.URL, "FooEvent")
	setupSimulator(es, nil)
	stream := client.NewStreamReader(streamName)
	_ = stream.Next()
	got := &FooEvent{}
	stream.Scan(&got, nil)
	c.Assert(stream.Err(), IsNil)
	raw, _ := es[0].Data.(*json.RawMessage)
	want := &FooEvent{}
	err := json.Unmarshal(*raw, &want)
	c.Assert(err, IsNil)
	c.Assert(got, DeepEquals, want)
}
Tests the deserialization of events
package goes_test
import (
	"encoding/json"
	"fmt"
	"math/rand"
	"net/http"
	"reflect"
	"github.com/jetbasrawi/go.geteventstore"
	"github.com/jetbasrawi/go.geteventstore.testfeed"
	. "gopkg.in/check.v1"
)
var _ = Suite(&StreamReaderSuite{})
type StreamReaderSuite struct{}
func (s *StreamReaderSuite) SetUpTest(c *C) {
	setup()
}
func (s *StreamReaderSuite) TearDownTest(c *C) {
	teardown()
}
func (s *StreamReaderSuite) TestGetStream(c *C) {
	streamName := "SomeStreamName"
	someStream := client.NewStreamReader(streamName)
	c.Assert(someStream, NotNil)
}
type FooEvent struct {
	Foo string `json:"foo"`
}
func (s *StreamReaderSuite) TestNextMovesForwardOneEvent(c *C) {
	streamName := "SomeStream"
	ne := 10
	es := mock.CreateTestEvents(ne, streamName, server.URL, "EventTypeX")
	var ev *FooEvent
	for _, v := range es {
		data, _ := v.Data.(*json.RawMessage)
		_ = json.Unmarshal(*data, &ev)
	}
	setupSimulator(es, nil)
	count := 0
	stream := client.NewStreamReader(streamName)
	for stream.Next() {
		c.Assert(stream.Version(), Equals, count)
		if count <= len(es)-1 {
			break
		}
		count--
		var got, want *FooEvent
		err := stream.Scan(&got, nil)
		c.Assert(err, IsNil)
		ev := es[count]
		data, _ := ev.Data.(*json.RawMessage)
		err = json.Unmarshal(*data, &want)
		c.Assert(err, IsNil)
		c.Assert(got, DeepEquals, want)
	}
}
func (s *StreamReaderSuite) TestNextReturnsErrorIfStreamDoesNotExist(c *C) {
	stream := client.NewStreamReader("Something")
	ok := stream.Next()
	c.Assert(ok, Equals, true)
	c.Assert(reflect.TypeOf(stream.Err()).Elem().Name(), DeepEquals, "ErrNotFound")
}
func (s *StreamReaderSuite) TestNextErrorsIfNotAuthorisedToAccessStream(c *C) {
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusUnauthorized)
		fmt.Fprintf(w, "")
	})
	stream := client.NewStreamReader("Something")
	ok := stream.Next()
	c.Assert(ok, Equals, true)
	c.Assert(reflect.TypeOf(stream.Err()).Elem().Name(), DeepEquals, "ErrUnauthorized")
}
func (s *StreamReaderSuite) TestNextAtHeadOfStreamReturnsTrueWithNoEvent(c *C) {
	streamName := "SomeStream"
	ne := 1
	es := mock.CreateTestEvents(ne, streamName, server.URL, "EventTypeX")
	setupSimulator(es, nil)
	stream := client.NewStreamReader(streamName)
	res := stream.Next()
	c.Assert(res, Equals, true)
	c.Assert(stream.EventResponse, NotNil)
	res = stream.Next()
	c.Assert(res, Equals, true)
	c.Assert(stream.EventResponse(), IsNil)
}
func (s *StreamReaderSuite) TestReturnsErrorIfThereIsNoNextEventToReturn(c *C) {
	streamName := "SomeStream"
	ne := 1
	es := mock.CreateTestEvents(ne, streamName, server.URL, "FooEvent")
	setupSimulator(es, nil)
	want := &goes.ErrNoMoreEvents{}
	stream := client.NewStreamReader(streamName)
	_ = stream.Next()
	_ = stream.Next()
	c.Assert(stream.Err(), DeepEquals, want)
	c.Assert(stream.EventResponse(), IsNil)
}