Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
chore: add move to epic testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
YCK1130 committed Aug 12, 2024
1 parent 8bc04fe commit e6ef7a5
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 31 deletions.
181 changes: 151 additions & 30 deletions application/jira/v0/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,28 @@ func TestComponent_GetIssueTask(t *testing.T) {
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Epic",
},
},
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Summary: "Test issue 4",
Status: "Done",
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Summary: "Test issue 4",
Description: "Test description 4",
Status: "Done",
IssueType: "Epic",
},
},
},
{
_type: "nok",
name: "404 - Not Found",
input: GetIssueInput{
IssueKey: "5",
IssueKey: "100",
UpdateHistory: true,
},
wantErr: "unsuccessful HTTP response.*",
Expand Down Expand Up @@ -207,26 +209,47 @@ func TestComponent_ListIssuesTask(t *testing.T) {
},
},
wantResp: ListIssuesOutput{
Total: 1,
Total: 2,
StartAt: 0,
MaxResults: 10,
Issues: []Issue{
{
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Epic",
},
},
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Status: "Done",
Summary: "Test issue 4",
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Description: "Test description 4",
Status: "Done",
Summary: "Test issue 4",
},
{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
},
IssueType: "Task",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/5",
Description: "Test description 5",
Status: "Done",
Summary: "Test issue 5",
},
},
},
Expand All @@ -243,26 +266,47 @@ func TestComponent_ListIssuesTask(t *testing.T) {
},
},
wantResp: ListIssuesOutput{
Total: 1,
Total: 2,
StartAt: 0,
MaxResults: 10,
Issues: []Issue{
{
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Epic",
},
},
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Status: "Done",
Summary: "Test issue 4",
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Description: "Test description 4",
Status: "Done",
Summary: "Test issue 4",
},
{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
},
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/5",
Description: "Test description 5",
Status: "Done",
Summary: "Test issue 5",
},
},
},
Expand All @@ -279,26 +323,47 @@ func TestComponent_ListIssuesTask(t *testing.T) {
},
},
wantResp: ListIssuesOutput{
Total: 1,
Total: 2,
StartAt: 0,
MaxResults: 10,
Issues: []Issue{
{
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Epic",
},
},
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Status: "Done",
Summary: "Test issue 4",
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Description: "Test description 4",
Status: "Done",
Summary: "Test issue 4",
},
{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
},
IssueType: "Task",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/5",
Description: "Test description 5",
Status: "Done",
Summary: "Test issue 5",
},
},
},
Expand All @@ -315,26 +380,47 @@ func TestComponent_ListIssuesTask(t *testing.T) {
},
},
wantResp: ListIssuesOutput{
Total: 1,
Total: 2,
StartAt: 0,
MaxResults: 10,
Issues: []Issue{
{
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Epic",
},
},
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Status: "Done",
Summary: "Test issue 4",
IssueType: "Epic",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/4",
Description: "Test description 4",
Status: "Done",
Summary: "Test issue 4",
},
{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
},
IssueType: "Task",
Self: "https://test.atlassian.net/rest/agile/1.0/issue/5",
Description: "Test description 5",
Status: "Done",
Summary: "Test issue 5",
},
},
},
Expand Down Expand Up @@ -584,6 +670,41 @@ func TestComponent_UpdateIssueTask(t *testing.T) {
},
},
},
{
_type: "ok",
name: "move issue to epic",
input: UpdateIssueInput{
IssueKey: "KAN-5",
Update: Update{
UpdateType: "Move Issue to Epic",
EpicKey: "KAN-4",
},
},
wantResp: UpdateIssueOutput{
Issue{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
"parent": map[string]interface{}{
"key": "KAN-4",
},
},
Self: "https://test.atlassian.net/rest/agile/1.0/issue/5",
Summary: "Test issue 5",
Status: "Done",
Description: "Test description 5",
IssueType: "Task",
},
},
},
{
_type: "nok",
name: "400 - Bad Request",
Expand Down
17 changes: 16 additions & 1 deletion application/jira/v0/mock_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ var fakeIssues = []FakeIssue{
ID: "4",
Key: "KAN-4",
Fields: map[string]interface{}{
"summary": "Test issue 4",
"summary": "Test issue 4",
"description": "Test description 4",
"status": map[string]interface{}{
"name": "Done",
},
Expand All @@ -109,6 +110,20 @@ var fakeIssues = []FakeIssue{
},
},
},
{
ID: "5",
Key: "KAN-5",
Fields: map[string]interface{}{
"summary": "Test issue 5",
"description": "Test description 5",
"status": map[string]interface{}{
"name": "Done",
},
"issuetype": map[string]interface{}{
"name": "Task",
},
},
},
}

type FakeSprint struct {
Expand Down
2 changes: 2 additions & 0 deletions application/jira/v0/mock_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func router(middlewares ...func(http.Handler) http.Handler) http.Handler {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte(`{"cloudId":"12345678-1234-1234-1234-123456789012"}`))
})

r.Post("/rest/agile/1.0/epic/{epic-key}/issue", mockMoveIssueToEpic)
r.Get("/rest/agile/1.0/issue/{issueIdOrKey:[a-zA-z0-9-]+}", mockGetIssue)
r.Get("/rest/agile/1.0/sprint/{sprintId}", mockGetSprint)
r.Put("/rest/agile/1.0/sprint/{sprintId}", mockUpdateSprint)
Expand Down
4 changes: 4 additions & 0 deletions application/jira/v0/mock_update_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ func mockUpdateIssue(res http.ResponseWriter, req *http.Request) {
return
}
}

func mockMoveIssueToEpic(res http.ResponseWriter, _ *http.Request) {
http.Error(res, "The request contains a next-gen issue", http.StatusBadRequest)
}

0 comments on commit e6ef7a5

Please sign in to comment.