Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables get wantlist. This closes #10 #11

Merged
merged 1 commit into from
Dec 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
}
}