Skip to content

Commit

Permalink
Merge 362e841 into eccb050
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherlogic committed Dec 31, 2018
2 parents eccb050 + 362e841 commit a4c3bef
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 25 deletions.
83 changes: 63 additions & 20 deletions proto/wantslist.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions proto/wantslist.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ message AddWantListResponse {}

message GetWantListRequest {}

message GetWantListResponse {}
message GetWantListResponse {
repeated WantList lists = 1;
}

service WantService {
rpc AddWantList(AddWantListRequest) returns (AddWantListResponse) {};
//rpc GetWantList(GetWantListRequest) returns (GetWantListResponse) {};
rpc GetWantList(GetWantListRequest) returns (GetWantListResponse) {};
}
2 changes: 1 addition & 1 deletion wantslist.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Init() *Server {

// DoRegister does RPC registration
func (s *Server) DoRegister(server *grpc.Server) {
//Pass
pb.RegisterWantServiceServer(server, s)
}

// ReportHealth alerts if we're not healthy
Expand Down
5 changes: 5 additions & 0 deletions wantslistapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ func (s *Server) AddWantList(ctx context.Context, req *pb.AddWantListRequest) (*
s.config.Lists = append(s.config.Lists, req.Add)
return &pb.AddWantListResponse{}, nil
}

//GetWantList gets a want list
func (s *Server) GetWantList(ctx context.Context, req *pb.GetWantListRequest) (*pb.GetWantListResponse, error) {
return &pb.GetWantListResponse{Lists: s.config.Lists}, nil
}
9 changes: 7 additions & 2 deletions wantslistapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ import (
pb "github.com/brotherlogic/wantslist/proto"
)

func TestAddWantsList(t *testing.T) {
func TestWantsList(t *testing.T) {
s := InitTestServer()

s.AddWantList(context.Background(), &pb.AddWantListRequest{Add: &pb.WantList{Name: "hello"}})
lists, err := s.GetWantList(context.Background(), &pb.GetWantListRequest{})

if len(s.config.Lists) != 1 {
if err != nil {
t.Fatalf("Error in getting lists: %v", err)
}

if len(lists.Lists) != 1 {
t.Errorf("Wrong number of lists: %v", len(s.config.Lists))
}
}

0 comments on commit a4c3bef

Please sign in to comment.