1
0
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:
Andy Grunwald 2016-06-03 18:18:01 +02:00
parent 0821e0283a
commit 4efa3df3b1
2 changed files with 25 additions and 0 deletions

View File

@ -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
}

View File

@ -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)
}
}