Ejemplo n.º 1
0
func setupForFailedFileLoad(cb *ctests.ClientContextBuilder) {

	// We have to unmarshal the received object, so we'll have to load some types.
	cb.Base.Path("")

	done := make(chan error, 1)
	done <- errors.New("error")

	cb.GetConnection().EXPECT().Go(shared.Data, gomock.Any(), gomock.Any(), gomock.Any()).Return(done)

}
Ejemplo n.º 2
0
func setupForSuccessfulFileLoad(t *testing.T, cb *ctests.ClientContextBuilder) {

	// We have to unmarshal the received object, so we'll have to load some types.
	cb.Base.Path("").Jauto().Sauto(parser.Parse)

	done := make(chan error, 1)

	do := func(method shared.Method, args interface{}, reply interface{}, fail chan error) chan error {
		// Create a simple ke object and marshal it to a []byte
		var bytes []byte
		bytes, err := system.Marshal(cb.Ctx(), &system.Object{Type: system.NewReference("system", "object")})
		require.NoError(t, err)
		reply.(*shared.DataResponse).Found = true
		reply.(*shared.DataResponse).Data = bytes
		close(done)
		return done
	}

	cb.GetConnection().EXPECT().Go(shared.Data, gomock.Any(), gomock.Any(), gomock.Any()).Do(do).Return(done)
}