mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-02-13 13:48:28 +02:00
Updates tests and examples to work with proposed changes
This commit is contained in:
parent
c6f546da3a
commit
02a41efba4
@ -67,7 +67,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
|
||||
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/", true)
|
||||
issue, _, _ := jiraClient.Issue.Get("MESOS-3325", nil)
|
||||
|
||||
fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
|
||||
@ -98,7 +98,7 @@ func main() {
|
||||
Password: "token",
|
||||
}
|
||||
|
||||
client, err := jira.NewClient(tp.Client(), "https://my.jira.com")
|
||||
client, err := jira.NewClient(tp.Client(), "https://my.jira.com", true)
|
||||
|
||||
u, _, err := client.User.Get("some_user")
|
||||
|
||||
@ -136,7 +136,7 @@ func main() {
|
||||
Password: "token",
|
||||
}
|
||||
|
||||
jiraClient, err := jira.NewClient(tp.Client(), base)
|
||||
jiraClient, err := jira.NewClient(tp.Client(), base, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -189,7 +189,7 @@ func main() {
|
||||
Password: "token",
|
||||
}
|
||||
|
||||
jiraClient, err := jira.NewClient(tp.Client(), base)
|
||||
jiraClient, err := jira.NewClient(tp.Client(), base, true)
|
||||
req, _ := jiraClient.NewRequest("GET", "rest/api/2/project", nil)
|
||||
|
||||
projects := new([]jira.Project)
|
||||
|
@ -29,7 +29,7 @@ func main() {
|
||||
Password: strings.TrimSpace(password),
|
||||
}
|
||||
|
||||
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL))
|
||||
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL), true)
|
||||
if err != nil {
|
||||
fmt.Printf("\nerror: %v\n", err)
|
||||
return
|
||||
|
@ -29,7 +29,7 @@ func main() {
|
||||
Password: strings.TrimSpace(password),
|
||||
}
|
||||
|
||||
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL))
|
||||
client, err := jira.NewClient(tp.Client(), strings.TrimSpace(jiraURL), true)
|
||||
if err != nil {
|
||||
fmt.Printf("\nerror: %v\n", err)
|
||||
return
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
jiraClient, _ := jira.NewClient(nil, "https://jira.atlassian.com/")
|
||||
jiraClient, _ := jira.NewClient(nil, "https://jira.atlassian.com/", true)
|
||||
req, _ := jiraClient.NewRequest("GET", "/rest/api/2/project", nil)
|
||||
|
||||
projects := new([]jira.Project)
|
||||
|
@ -14,7 +14,7 @@ func main() {
|
||||
}
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
jiraClient, _ := jira.NewClient(client, "https://issues.apache.org/jira/")
|
||||
jiraClient, _ := jira.NewClient(client, "https://issues.apache.org/jira/", true)
|
||||
issue, _, _ := jiraClient.Issue.Get("MESOS-3325", nil)
|
||||
|
||||
fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/")
|
||||
jiraClient, _ := jira.NewClient(nil, "https://issues.apache.org/jira/", true)
|
||||
issue, _, _ := jiraClient.Issue.Get("MESOS-3325", nil)
|
||||
|
||||
fmt.Printf("%s: %+v\n", issue.Key, issue.Fields.Summary)
|
||||
|
@ -42,7 +42,7 @@ func main() {
|
||||
tp = ba.Client()
|
||||
}
|
||||
|
||||
client, err := jira.NewClient(tp, strings.TrimSpace(jiraURL))
|
||||
client, err := jira.NewClient(tp, strings.TrimSpace(jiraURL), true)
|
||||
if err != nil {
|
||||
fmt.Printf("\nerror: %v\n", err)
|
||||
return
|
||||
|
58
jira_test.go
58
jira_test.go
@ -38,7 +38,7 @@ func setup() {
|
||||
testServer = httptest.NewServer(testMux)
|
||||
|
||||
// jira client configured to use test server
|
||||
testClient, _ = NewClient(nil, testServer.URL)
|
||||
testClient, _ = NewClient(nil, testServer.URL, true)
|
||||
}
|
||||
|
||||
// teardown closes the test HTTP server.
|
||||
@ -59,7 +59,7 @@ func testRequestURL(t *testing.T, r *http.Request, want string) {
|
||||
}
|
||||
|
||||
func TestNewClient_WrongUrl(t *testing.T) {
|
||||
c, err := NewClient(nil, "://issues.apache.org/jira/")
|
||||
c, err := NewClient(nil, "://issues.apache.org/jira/", true)
|
||||
|
||||
if err == nil {
|
||||
t.Error("Expected an error. Got none")
|
||||
@ -72,7 +72,7 @@ func TestNewClient_WrongUrl(t *testing.T) {
|
||||
func TestNewClient_WithHttpClient(t *testing.T) {
|
||||
httpClient := http.DefaultClient
|
||||
httpClient.Timeout = 10 * time.Minute
|
||||
c, err := NewClient(httpClient, testJIRAInstanceURL)
|
||||
c, err := NewClient(httpClient, testJIRAInstanceURL, true)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Got an error: %s", err)
|
||||
@ -86,7 +86,7 @@ func TestNewClient_WithHttpClient(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewClient_WithServices(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Got an error: %s", err)
|
||||
@ -142,7 +142,7 @@ func TestCheckResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewRequest(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -164,7 +164,7 @@ func TestClient_NewRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewRawRequest(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -197,7 +197,7 @@ func testURLParseError(t *testing.T, err error) {
|
||||
}
|
||||
|
||||
func TestClient_NewRequest_BadURL(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -206,7 +206,7 @@ func TestClient_NewRequest_BadURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewRequest_SessionCookies(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -235,7 +235,7 @@ func TestClient_NewRequest_SessionCookies(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewRequest_BasicAuth(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -261,7 +261,7 @@ func TestClient_NewRequest_BasicAuth(t *testing.T) {
|
||||
// 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 TestClient_NewRequest_EmptyBody(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -275,7 +275,7 @@ func TestClient_NewRequest_EmptyBody(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewMultiPartRequest(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -308,7 +308,7 @@ func TestClient_NewMultiPartRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestClient_NewMultiPartRequest_BasicAuth(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("An error occurred. Expected nil. Got %+v.", err)
|
||||
}
|
||||
@ -427,7 +427,7 @@ func TestClient_GetBaseURL_WithURL(t *testing.T) {
|
||||
t.Errorf("URL parsing -> Got an error: %s", err)
|
||||
}
|
||||
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
c, err := NewClient(nil, testJIRAInstanceURL, true)
|
||||
if err != nil {
|
||||
t.Errorf("Client creation -> Got an error: %s", err)
|
||||
}
|
||||
@ -440,30 +440,6 @@ func TestClient_GetBaseURL_WithURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVED : This actually calls a live URL. It's not a unit test.
|
||||
// I'm also not really sure what it's testing.
|
||||
// func TestClient_Do_PagingInfoEmptyByDefault(t *testing.T) {
|
||||
// c, _ := NewClient(nil, testJIRAInstanceURL)
|
||||
// req, _ := c.NewRequest("GET", "/", nil)
|
||||
// t.Errorf("%v\n", req)
|
||||
// type foo struct {
|
||||
// A string
|
||||
// }
|
||||
// body := new(foo)
|
||||
|
||||
// resp, _ := c.Do(req, body)
|
||||
|
||||
// if resp.StartAt != 0 {
|
||||
// t.Errorf("StartAt not equal to 0")
|
||||
// }
|
||||
// if resp.MaxResults != 0 {
|
||||
// t.Errorf("StartAt not equal to 0")
|
||||
// }
|
||||
// if resp.Total != 0 {
|
||||
// t.Errorf("StartAt not equal to 0")
|
||||
// }
|
||||
// }
|
||||
|
||||
func TestBasicAuthTransport(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
@ -488,7 +464,7 @@ func TestBasicAuthTransport(t *testing.T) {
|
||||
Password: password,
|
||||
}
|
||||
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL)
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL, true)
|
||||
req, _ := basicAuthClient.NewRequest("GET", ".", nil)
|
||||
basicAuthClient.Do(req, nil)
|
||||
}
|
||||
@ -539,7 +515,7 @@ func TestCookieAuthTransport_SessionObject_Exists(t *testing.T) {
|
||||
SessionObject: []*http.Cookie{testCookie},
|
||||
}
|
||||
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL)
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL, true)
|
||||
req, _ := basicAuthClient.NewRequest("GET", ".", nil)
|
||||
basicAuthClient.Do(req, nil)
|
||||
}
|
||||
@ -575,7 +551,7 @@ func TestCookieAuthTransport_SessionObject_ExistsWithEmptyCookie(t *testing.T) {
|
||||
SessionObject: []*http.Cookie{emptyCookie, testCookie},
|
||||
}
|
||||
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL)
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL, true)
|
||||
req, _ := basicAuthClient.NewRequest("GET", ".", nil)
|
||||
basicAuthClient.Do(req, nil)
|
||||
}
|
||||
@ -616,7 +592,7 @@ func TestCookieAuthTransport_SessionObject_DoesNotExist(t *testing.T) {
|
||||
AuthURL: ts.URL,
|
||||
}
|
||||
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL)
|
||||
basicAuthClient, _ := NewClient(tp.Client(), testServer.URL, true)
|
||||
req, _ := basicAuthClient.NewRequest("GET", ".", nil)
|
||||
basicAuthClient.Do(req, nil)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user