mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-24 08:22:42 +02:00
Renamed unit tests according golang standard
This commit is contained in:
parent
f1a11a0302
commit
cdb3939c4c
@ -8,7 +8,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAcquireSessionCookie_Fail(t *testing.T) {
|
||||
func TestAuthenticationService_AcquireSessionCookie_Failure(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/auth/1/session", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -42,7 +42,7 @@ func TestAcquireSessionCookie_Fail(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAcquireSessionCookie_Success(t *testing.T) {
|
||||
func TestAuthenticationService_AcquireSessionCookie_Success(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/auth/1/session", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -75,7 +75,7 @@ func TestAcquireSessionCookie_Success(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthenticated_NotInit(t *testing.T) {
|
||||
func TestAuthenticationService_Authenticated(t *testing.T) {
|
||||
// Skip setup() because we don't want a fully setup client
|
||||
testClient = new(Client)
|
||||
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIssueGet_Success(t *testing.T) {
|
||||
func TestIssueService_Get_Success(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -29,7 +29,7 @@ func TestIssueGet_Success(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueCreate(t *testing.T) {
|
||||
func TestIssueService_Create(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -54,7 +54,7 @@ func TestIssueCreate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueAddComment(t *testing.T) {
|
||||
func TestIssueService_AddComment(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10000/comment", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -81,7 +81,7 @@ func TestIssueAddComment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueAddLink(t *testing.T) {
|
||||
func TestIssueService_AddLink(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issueLink", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -121,7 +121,7 @@ func TestIssueAddLink(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueFields(t *testing.T) {
|
||||
func TestIssueService_Get_Fields(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -148,7 +148,7 @@ func TestIssueFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueDownloadAttachment(t *testing.T) {
|
||||
func TestIssueService_DownloadAttachment(t *testing.T) {
|
||||
var testAttachment = "Here is an attachment"
|
||||
|
||||
setup()
|
||||
@ -183,7 +183,7 @@ func TestIssueDownloadAttachment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssueDownloadAttachment_BadStatus(t *testing.T) {
|
||||
func TestIssueService_DownloadAttachment_BadStatus(t *testing.T) {
|
||||
|
||||
setup()
|
||||
defer teardown()
|
||||
@ -208,7 +208,7 @@ func TestIssueDownloadAttachment_BadStatus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssuePostAttachment(t *testing.T) {
|
||||
func TestIssueService_PostAttachment(t *testing.T) {
|
||||
var testAttachment = "Here is an attachment"
|
||||
|
||||
setup()
|
||||
@ -258,7 +258,7 @@ func TestIssuePostAttachment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssuePostAttachment_NoResponse(t *testing.T) {
|
||||
func TestIssueService_PostAttachment_NoResponse(t *testing.T) {
|
||||
var testAttachment = "Here is an attachment"
|
||||
|
||||
setup()
|
||||
@ -277,7 +277,7 @@ func TestIssuePostAttachment_NoResponse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssuePostAttachment_NoFilename(t *testing.T) {
|
||||
func TestIssueService_PostAttachment_NoFilename(t *testing.T) {
|
||||
var testAttachment = "Here is an attachment"
|
||||
|
||||
setup()
|
||||
@ -297,8 +297,7 @@ func TestIssuePostAttachment_NoFilename(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssuePostAttachment_NoAttachment(t *testing.T) {
|
||||
|
||||
func TestIssueService_PostAttachment_NoAttachment(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10000/attachments", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -315,8 +314,7 @@ func TestIssuePostAttachment_NoAttachment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue_Search(t *testing.T) {
|
||||
|
||||
func TestIssueService_Search(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/search", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -347,8 +345,7 @@ func TestIssue_Search(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue_SearchWithoutPaging(t *testing.T) {
|
||||
|
||||
func TestIssueService_Search_WithoutPaging(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/search", func(w http.ResponseWriter, r *http.Request) {
|
||||
@ -378,7 +375,7 @@ func TestIssue_SearchWithoutPaging(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_CustomFields(t *testing.T) {
|
||||
func TestIssueService_GetCustomFields(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||
|
31
jira_test.go
31
jira_test.go
@ -97,9 +97,18 @@ func TestNewClient_WithServices(t *testing.T) {
|
||||
if c.Issue == nil {
|
||||
t.Error("No IssueService provided")
|
||||
}
|
||||
if c.Project == nil {
|
||||
t.Error("No ProjectService provided")
|
||||
}
|
||||
if c.Board == nil {
|
||||
t.Error("No BoardService provided")
|
||||
}
|
||||
if c.Sprint == nil {
|
||||
t.Error("No SprintService provided")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckResponse_GoodResults(t *testing.T) {
|
||||
func TestCheckResponse(t *testing.T) {
|
||||
codes := []int{
|
||||
http.StatusOK, http.StatusPartialContent, 299,
|
||||
}
|
||||
@ -114,7 +123,7 @@ func TestCheckResponse_GoodResults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRequest(t *testing.T) {
|
||||
func TestClient_NewRequest(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("An error occured. Expected nil. Got %+v.", err)
|
||||
@ -136,7 +145,7 @@ func TestNewRequest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRequest_InvalidJSON(t *testing.T) {
|
||||
func TestClient_NewRequest_InvalidJSON(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("An error occured. Expected nil. Got %+v.", err)
|
||||
@ -164,7 +173,7 @@ func testURLParseError(t *testing.T, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewRequest_BadURL(t *testing.T) {
|
||||
func TestClient_NewRequest_BadURL(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("An error occured. Expected nil. Got %+v.", err)
|
||||
@ -177,7 +186,7 @@ func TestNewRequest_BadURL(t *testing.T) {
|
||||
// In most cases, passing an io.Reader that returns no content is fine,
|
||||
// since there is no difference between an HTTP request body that is an empty string versus one that is not set at all.
|
||||
// However in certain cases, intermediate systems may treat these differently resulting in subtle errors.
|
||||
func TestNewRequest_EmptyBody(t *testing.T) {
|
||||
func TestClient_NewRequest_EmptyBody(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("An error occured. Expected nil. Got %+v.", err)
|
||||
@ -191,7 +200,7 @@ func TestNewRequest_EmptyBody(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDo(t *testing.T) {
|
||||
func TestClient_Do(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
@ -216,7 +225,7 @@ func TestDo(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDo_HTTPResponse(t *testing.T) {
|
||||
func TestClient_Do_HTTPResponse(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
@ -242,7 +251,7 @@ func TestDo_HTTPResponse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDo_HTTPError(t *testing.T) {
|
||||
func TestClient_Do_HTTPError(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
@ -260,7 +269,7 @@ func TestDo_HTTPError(t *testing.T) {
|
||||
|
||||
// Test handling of an error caused by the internal http client's Do() function.
|
||||
// A redirect loop is pretty unlikely to occur within the Gerrit API, but does allow us to exercise the right code path.
|
||||
func TestDo_RedirectLoop(t *testing.T) {
|
||||
func TestClient_Do_RedirectLoop(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
@ -279,7 +288,7 @@ func TestDo_RedirectLoop(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBaseURL_WithURL(t *testing.T) {
|
||||
func TestClient_GetBaseURL_WithURL(t *testing.T) {
|
||||
u, err := url.Parse(testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("URL parsing -> Got an error: %s", err)
|
||||
@ -298,7 +307,7 @@ func TestGetBaseURL_WithURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPagingInfoEmptyByDefault(t *testing.T) {
|
||||
func TestClient_Do_PagingInfoEmptyByDefault(t *testing.T) {
|
||||
c, _ := NewClient(nil, testJIRAInstanceURL)
|
||||
req, _ := c.NewRequest("GET", "/", nil)
|
||||
type foo struct {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProjectGetAll(t *testing.T) {
|
||||
func TestProjectService_GetList(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testAPIEdpoint := "/rest/api/2/project"
|
||||
@ -31,7 +31,7 @@ func TestProjectGetAll(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectGet(t *testing.T) {
|
||||
func TestProjectService_Get(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testAPIEdpoint := "/rest/api/2/project/12310505"
|
||||
@ -55,7 +55,7 @@ func TestProjectGet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectGet_NoProject(t *testing.T) {
|
||||
func TestProjectService_Get_NoProject(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
testAPIEdpoint := "/rest/api/2/project/99999999"
|
||||
|
Loading…
Reference in New Issue
Block a user