Skip to content
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
14 changes: 14 additions & 0 deletions githubtasksapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ func (s *Server) AddTask(ctx context.Context, req *pb.AddTaskRequest) (*pb.AddTa

return nil, fmt.Errorf("Could not locate milestone %v/%v", req.GetMilestoneName(), req.GetMilestoneNumber())
}

// GetMilestones for the system
func (s *Server) GetMilestones(ctx context.Context, req *pb.GetMilestonesRequest) (*pb.GetMilestonesResponse, error) {
resp := &pb.GetMilestonesResponse{Milestones: []*pb.Milestone{}}
for _, p := range s.config.GetProjects() {
for _, m := range p.GetMilestones() {
if m.GetGithubProject() == req.GetGithubProject() {
resp.Milestones = append(resp.Milestones, m)
}
}
}

return resp, nil
}
12 changes: 10 additions & 2 deletions githubtasksapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ func TestAddProject(t *testing.T) {
s := InitTestServer()

s.AddProject(context.Background(),
&pb.AddProjectRequest{Add: &pb.Project{Name: "test project", Milestones: []*pb.Milestone{&pb.Milestone{Name: "Testing", Number: 1}}}})
&pb.AddProjectRequest{Add: &pb.Project{Name: "test project", Milestones: []*pb.Milestone{&pb.Milestone{Name: "Testing", Number: 1, GithubProject: "madeup"}}}})

if len(s.config.GetProjects()) != 1 {
t.Errorf("Project was not added")
}

_, err := s.AddTask(context.Background(),
resp, err := s.GetMilestones(context.Background(), &pb.GetMilestonesRequest{GithubProject: "madeup"})
if err != nil {
t.Fatalf("Error getting milestones: %v", err)
}
if len(resp.GetMilestones()) != 1 {
t.Fatalf("Milestone not created correctly: %v", resp)
}

_, err = s.AddTask(context.Background(),
&pb.AddTaskRequest{MilestoneName: "Testing", MilestoneNumber: 1, Title: "Add stuff", Body: "Do Stuff"})

if err != nil {
Expand Down
222 changes: 187 additions & 35 deletions proto/githubtasks.pb.go

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

9 changes: 9 additions & 0 deletions proto/githubtasks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,17 @@ message AddTaskResponse {
Task task = 1;
}

message GetMilestonesRequest{
string github_project = 1;
}

message GetMilestonesResponse {
repeated Milestone milestones = 1;
}

service TasksService {
rpc AddProject(AddProjectRequest) returns (AddProjectResponse) {};
//rpc UpdateProject(UpdateProjectRequest) returns (UpdateProjectResponse) {};
rpc AddTask(AddTaskRequest) returns (AddTaskResponse) {};
rpc GetMilestones(GetMilestonesRequest) returns (GetMilestonesResponse) {};
}