mirror of
				https://github.com/interviewstreet/go-jira.git
				synced 2025-10-30 23:47:46 +02:00 
			
		
		
		
	test: Add unit test for priority api
This commit is contained in:
		
							
								
								
									
										42
									
								
								mocks/all_priorities.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								mocks/all_priorities.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| [ | ||||
|   { | ||||
|     "self": "https://issues.apache.org/jira/rest/api/2/priority/1", | ||||
|     "statusColor": "#cc0000", | ||||
|     "description": "Blocks development and/or testing work, production could not run", | ||||
|     "iconUrl": "https://issues.apache.org/jira/images/icons/priorities/blocker.svg", | ||||
|     "name": "Blocker", | ||||
|     "id": "1" | ||||
|   }, | ||||
|   { | ||||
|     "self": "https://issues.apache.org/jira/rest/api/2/priority/2", | ||||
|     "statusColor": "#ff0000", | ||||
|     "description": "Crashes, loss of data, severe memory leak.", | ||||
|     "iconUrl": "https://issues.apache.org/jira/images/icons/priorities/critical.svg", | ||||
|     "name": "Critical", | ||||
|     "id": "2" | ||||
|   }, | ||||
|   { | ||||
|     "self": "https://issues.apache.org/jira/rest/api/2/priority/3", | ||||
|     "statusColor": "#009900", | ||||
|     "description": "Major loss of function.", | ||||
|     "iconUrl": "https://issues.apache.org/jira/images/icons/priorities/major.svg", | ||||
|     "name": "Major", | ||||
|     "id": "3" | ||||
|   }, | ||||
|   { | ||||
|     "self": "https://issues.apache.org/jira/rest/api/2/priority/4", | ||||
|     "statusColor": "#006600", | ||||
|     "description": "Minor loss of function, or other problem where easy workaround is present.", | ||||
|     "iconUrl": "https://issues.apache.org/jira/images/icons/priorities/minor.svg", | ||||
|     "name": "Minor", | ||||
|     "id": "4" | ||||
|   }, | ||||
|   { | ||||
|     "self": "https://issues.apache.org/jira/rest/api/2/priority/5", | ||||
|     "statusColor": "#003300", | ||||
|     "description": "Cosmetic problem like misspelt words or misaligned text.", | ||||
|     "iconUrl": "https://issues.apache.org/jira/images/icons/priorities/trivial.svg", | ||||
|     "name": "Trivial", | ||||
|     "id": "5" | ||||
|   } | ||||
| ] | ||||
| @@ -29,7 +29,7 @@ func (s *PriorityService) GetList() ([]Priority, *Response, error) { | ||||
| 	} | ||||
|  | ||||
| 	priorityList := []Priority{} | ||||
| 	resp, err := s.client.Do(req, priorityList) | ||||
| 	resp, err := s.client.Do(req, &priorityList) | ||||
| 	if err != nil { | ||||
| 		return nil, resp, NewJiraError(resp, err) | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										32
									
								
								priority_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								priority_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| package jira | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| 	"testing" | ||||
| ) | ||||
|  | ||||
| func TestPriorityService_GetList(t *testing.T) { | ||||
| 	setup() | ||||
| 	defer teardown() | ||||
| 	testAPIEdpoint := "/rest/api/2/priority" | ||||
|  | ||||
| 	raw, err := ioutil.ReadFile("./mocks/all_priorities.json") | ||||
| 	if err != nil { | ||||
| 		t.Error(err.Error()) | ||||
| 	} | ||||
| 	testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) { | ||||
| 		testMethod(t, r, "GET") | ||||
| 		testRequestURL(t, r, testAPIEdpoint) | ||||
| 		fmt.Fprint(w, string(raw)) | ||||
| 	}) | ||||
|  | ||||
| 	priorities, _, err := testClient.Priority.GetList() | ||||
| 	if priorities == nil { | ||||
| 		t.Error("Expected priority list. Priority list is nil") | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Error given: %s", err) | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user