Enable all tests (fix #25)

This commit is contained in:
Manfred Touron
2017-03-16 15:41:09 +01:00
parent 191df6c8ec
commit 97cfa60fc8
21 changed files with 123 additions and 86 deletions

View File

@@ -1,11 +1,12 @@
package user_clientgrpc
import (
context "context"
jwt "github.com/go-kit/kit/auth/jwt"
"github.com/go-kit/kit/endpoint"
"github.com/go-kit/kit/log"
grpctransport "github.com/go-kit/kit/transport/grpc"
context "golang.org/x/net/context"
"google.golang.org/grpc"
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"

View File

@@ -1,14 +1,17 @@
package user_endpoints
import (
context "context"
"fmt"
"github.com/go-kit/kit/endpoint"
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
context "golang.org/x/net/context"
oldcontext "golang.org/x/net/context"
)
var _ = endpoint.Chain
var _ = fmt.Errorf
var _ = context.Background
type StreamEndpoint func(server interface{}, req interface{}) (err error)
@@ -18,7 +21,7 @@ type Endpoints struct {
GetUserEndpoint endpoint.Endpoint
}
func (e *Endpoints) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
func (e *Endpoints) CreateUser(ctx oldcontext.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
out, err := e.CreateUserEndpoint(ctx, in)
if err != nil {
return &pb.CreateUserResponse{ErrMsg: err.Error()}, err
@@ -26,7 +29,7 @@ func (e *Endpoints) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*
return out.(*pb.CreateUserResponse), err
}
func (e *Endpoints) GetUser(ctx context.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) {
func (e *Endpoints) GetUser(ctx oldcontext.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) {
out, err := e.GetUserEndpoint(ctx, in)
if err != nil {
return &pb.GetUserResponse{ErrMsg: err.Error()}, err

View File

@@ -1,4 +1,4 @@
// Code generated by protoc-gen-gogo.
// Code generated by protoc-gen-go.
// source: services/user/user.proto
// DO NOT EDIT!
@@ -17,7 +17,7 @@ It has these top-level messages:
*/
package user
import proto "github.com/gogo/protobuf/proto"
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
@@ -35,16 +35,16 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type CreateUserRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *CreateUserRequest) Reset() { *m = CreateUserRequest{} }
func (m *CreateUserRequest) String() string { return proto.CompactTextString(m) }
func (*CreateUserRequest) ProtoMessage() {}
func (*CreateUserRequest) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{0} }
func (*CreateUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *CreateUserRequest) GetName() string {
if m != nil {
@@ -55,13 +55,13 @@ func (m *CreateUserRequest) GetName() string {
type CreateUserResponse struct {
User *User `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg" json:"err_msg,omitempty"`
}
func (m *CreateUserResponse) Reset() { *m = CreateUserResponse{} }
func (m *CreateUserResponse) String() string { return proto.CompactTextString(m) }
func (*CreateUserResponse) ProtoMessage() {}
func (*CreateUserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{1} }
func (*CreateUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *CreateUserResponse) GetUser() *User {
if m != nil {
@@ -78,13 +78,13 @@ func (m *CreateUserResponse) GetErrMsg() string {
}
type GetUserRequest struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
}
func (m *GetUserRequest) Reset() { *m = GetUserRequest{} }
func (m *GetUserRequest) String() string { return proto.CompactTextString(m) }
func (*GetUserRequest) ProtoMessage() {}
func (*GetUserRequest) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{2} }
func (*GetUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *GetUserRequest) GetId() string {
if m != nil {
@@ -95,13 +95,13 @@ func (m *GetUserRequest) GetId() string {
type GetUserResponse struct {
User *User `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`
ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg" json:"err_msg,omitempty"`
}
func (m *GetUserResponse) Reset() { *m = GetUserResponse{} }
func (m *GetUserResponse) String() string { return proto.CompactTextString(m) }
func (*GetUserResponse) ProtoMessage() {}
func (*GetUserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{3} }
func (*GetUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *GetUserResponse) GetUser() *User {
if m != nil {
@@ -118,14 +118,14 @@ func (m *GetUserResponse) GetErrMsg() string {
}
type User struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
}
func (m *User) Reset() { *m = User{} }
func (m *User) String() string { return proto.CompactTextString(m) }
func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{4} }
func (*User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *User) GetId() string {
if m != nil {
@@ -254,11 +254,11 @@ var _UserService_serviceDesc = grpc.ServiceDesc{
Metadata: "services/user/user.proto",
}
func init() { proto.RegisterFile("services/user/user.proto", fileDescriptorUser) }
func init() { proto.RegisterFile("services/user/user.proto", fileDescriptor0) }
var fileDescriptorUser = []byte{
var fileDescriptor0 = []byte{
// 236 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x2d, 0x2a,
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x2d, 0x2a,
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x2d, 0x4e, 0x2d, 0x02, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25,
0xf9, 0x42, 0x2c, 0x20, 0xb6, 0x92, 0x3a, 0x97, 0xa0, 0x73, 0x51, 0x6a, 0x62, 0x49, 0x6a, 0x68,
0x71, 0x6a, 0x51, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x10, 0x17, 0x4b, 0x5e, 0x62,

View File

@@ -1,10 +1,11 @@
package user_grpctransport
import (
context "context"
"fmt"
grpctransport "github.com/go-kit/kit/transport/grpc"
context "golang.org/x/net/context"
oldcontext "golang.org/x/net/context"
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
@@ -14,7 +15,8 @@ import (
var _ = fmt.Errorf
func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.UserServiceServer {
options := []grpctransport.ServerOption{}
var options []grpctransport.ServerOption
_ = options
return &grpcServer{
createuser: grpctransport.NewServer(
@@ -41,7 +43,7 @@ type grpcServer struct {
getuser grpctransport.Handler
}
func (s *grpcServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
func (s *grpcServer) CreateUser(ctx oldcontext.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
_, rep, err := s.createuser.ServeGRPC(ctx, req)
if err != nil {
return nil, err
@@ -54,7 +56,7 @@ func encodeCreateUserResponse(ctx context.Context, response interface{}) (interf
return resp, nil
}
func (s *grpcServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) {
func (s *grpcServer) GetUser(ctx oldcontext.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) {
_, rep, err := s.getuser.ServeGRPC(ctx, req)
if err != nil {
return nil, err

View File

@@ -1,8 +1,8 @@
package user_httptransport
import (
"context"
"encoding/json"
context "golang.org/x/net/context"
"log"
"net/http"
@@ -12,6 +12,10 @@ import (
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
)
var _ = log.Printf
var _ = gokit_endpoint.Chain
var _ = httptransport.NewClient
func MakeCreateUserHandler(ctx context.Context, svc pb.UserServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
return httptransport.NewServer(
ctx,