mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-24 08:22:42 +02:00
Fix #12: Expose the base JIRA URL
This commit is contained in:
parent
0821e0283a
commit
4efa3df3b1
6
jira.go
6
jira.go
@ -152,3 +152,9 @@ func CheckResponse(r *http.Response) error {
|
||||
err := fmt.Errorf("Request failed. Please analyze the request body for more details. Status code: %d", r.StatusCode)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetBaseURL will return you the Base URL.
|
||||
// This is the same URL as in the NewClient constructor
|
||||
func (c *Client) GetBaseURL() url.URL {
|
||||
return *c.baseURL
|
||||
}
|
||||
|
19
jira_test.go
19
jira_test.go
@ -277,3 +277,22 @@ func TestDo_RedirectLoop(t *testing.T) {
|
||||
t.Errorf("Expected a URL error; got %+v.", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBaseURL_WithURL(t *testing.T) {
|
||||
u, err := url.Parse(testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("URL parsing -> Got an error: %s", err)
|
||||
}
|
||||
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("Client creation -> Got an error: %s", err)
|
||||
}
|
||||
if c == nil {
|
||||
t.Error("Expected a client. Got none")
|
||||
}
|
||||
|
||||
if b := c.GetBaseURL(); !reflect.DeepEqual(b, *u) {
|
||||
t.Errorf("Base URLs are not equal. Expected %+v, got %+v", *u, b)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user