Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Reorder TestReorderIssue() function
Browse files Browse the repository at this point in the history
  • Loading branch information
inputvalidation authored Jan 13, 2024
1 parent 5e4c6d4 commit 2a5b6e1
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,35 @@ func TestDeleteIssue(t *testing.T) {
}
}

func TestReorderIssue(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/projects/1/issues/5/reorder", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
fmt.Fprint(w, `{"id":1, "title" : "Reordered issue", "description": "This is the description of a reordered issue", "author" : {"id" : 1, "name": "corrie"}, "assignees":[{"id":1}]}`)
})

afterID := 100
opt := ReorderIssueOptions{MoveAfterID: &afterID}

issue, _, err := client.Issues.ReorderIssue("1", 5, &opt)
if err != nil {
log.Fatal(err)
}

want := &Issue{
ID: 1,
Title: "Reordered issue",
Description: "This is the description of a reordered issue",
Author: &IssueAuthor{ID: 1, Name: "corrie"},
Assignees: []*IssueAssignee{{ID: 1}},
}

if !reflect.DeepEqual(want, issue) {
t.Errorf("Issues.ReorderIssue returned %+v, want %+v", issue, want)
}
}

func TestMoveIssue(t *testing.T) {
mux, client := setup(t)

Expand Down Expand Up @@ -931,32 +960,3 @@ func TestGetIssueGroupMilestone(t *testing.T) {
t.Errorf("Issues.GetIssue returned %+v, want %+v", issue, want)
}
}

func TestReorderIssue(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/projects/1/issues/5/reorder", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
fmt.Fprint(w, `{"id":1, "title" : "Reordered issue", "description": "This is the description of a reordered issue", "author" : {"id" : 1, "name": "corrie"}, "assignees":[{"id":1}]}`)
})

afterID := 100
opt := ReorderIssueOptions{MoveAfterID: &afterID}

issue, _, err := client.Issues.ReorderIssue("1", 5, &opt)
if err != nil {
log.Fatal(err)
}

want := &Issue{
ID: 1,
Title: "Reordered issue",
Description: "This is the description of a reordered issue",
Author: &IssueAuthor{ID: 1, Name: "corrie"},
Assignees: []*IssueAssignee{{ID: 1}},
}

if !reflect.DeepEqual(want, issue) {
t.Errorf("Issues.ReorderIssue returned %+v, want %+v", issue, want)
}
}

0 comments on commit 2a5b6e1

Please sign in to comment.