feat(issues): add tracked time deletion
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
35cf9664de
commit
a555c24a9f
2 changed files with 26 additions and 0 deletions
|
|
@ -218,6 +218,12 @@ func (s *IssueService) ResetTime(ctx context.Context, owner, repo string, index
|
|||
return s.client.Delete(ctx, path)
|
||||
}
|
||||
|
||||
// DeleteTime removes a specific tracked time entry from an issue.
|
||||
func (s *IssueService) DeleteTime(ctx context.Context, owner, repo string, index, timeID int64) error {
|
||||
path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/times/{id}", pathParams("owner", owner, "repo", repo, "index", int64String(index), "id", int64String(timeID)))
|
||||
return s.client.Delete(ctx, path)
|
||||
}
|
||||
|
||||
// AddLabels adds labels to an issue.
|
||||
func (s *IssueService) AddLabels(ctx context.Context, owner, repo string, index int64, labelIDs []int64) error {
|
||||
path := ResolvePath("/api/v1/repos/{owner}/{repo}/issues/{index}/labels", pathParams("owner", owner, "repo", repo, "index", int64String(index)))
|
||||
|
|
|
|||
|
|
@ -1196,6 +1196,26 @@ func TestIssueService_ResetTime_Good(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestIssueService_DeleteTime_Good(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodDelete {
|
||||
t.Errorf("expected DELETE, got %s", r.Method)
|
||||
}
|
||||
if r.URL.Path != "/api/v1/repos/core/go-forge/issues/42/times/99" {
|
||||
t.Errorf("wrong path: %s", r.URL.Path)
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
}))
|
||||
defer srv.Close()
|
||||
|
||||
f := NewForge(srv.URL, "tok")
|
||||
if err := f.Issues.DeleteTime(context.Background(), "core", "go-forge", 42, 99); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueService_List_Bad(t *testing.T) {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue