Orion icon indicating copy to clipboard operation
Orion copied to clipboard

Examples should have tests as well

Open staceytay opened this issue 7 years ago • 4 comments

Would like example/echo/service/service.go to have sample tests that shows examples on how to test an Orion service, for both gRPC and http requests.

The context for this is that I'm attempting to write tests for https://github.com/carousell/SSO and so would like to refer to effective and efficient ways to test the service. For example, how to create a test an Orion service with the database functions mocked.

I tried creating a sample service

	service := &ssoServiceImpl{
		true,
		&djangoService{},
		"i63t3cfyumyMY2mY2DLM3HJQKYvGu24H",
		securecookie.New([]byte("i63t3cfyumyMY2mY2DLM3HJQKYvGu24H"), []byte("v6D83W7i6CJc7suVQzEEQPbu6mdNsrW6")),
		&storageClient{},
	}

	req := new(proto.LoginRequest)
	service.Login(ctx, req)

but this doesn't allow me to test for the http response codes and headers

staceytay avatar Dec 18 '17 10:12 staceytay

Agreed, will take it up once orion is feature complete! Please feel free to contribute till then

ankurs avatar Dec 18 '17 14:12 ankurs

I am getting error while trying out the examples.

For stringsvc example, in generated file stringproto.proto.orion.pb.go, getting following erro:

cannot use &_StringService_serviceDesc (type *"google.golang.org/grpc".ServiceDesc) as type *"github.com/carousell/Orion/vendor/google.golang.org/grpc".ServiceDesc in argument to orionServer.RegisterServicego

Please advise, thanks

kapeel-mopkar avatar Jan 17 '19 12:01 kapeel-mopkar

Kapeel, this is most likely because of missing vendor package, can you update your vendor and check ?

ankurs avatar Jan 17 '19 12:01 ankurs

@ankurs : pls ignore my earlier comment.

I have got the code working on my windows env. I had to run govendor fetch github.com/carousell/Orion/orion

Thnaks for your help

kapeel-mopkar avatar Jan 20 '19 11:01 kapeel-mopkar