mirror of
https://github.com/interviewstreet/go-jira.git
synced 2024-11-28 08:39:03 +02:00
Add test for NewRawRequest
This commit is contained in:
parent
dad2a7214f
commit
16619653d8
24
jira_test.go
24
jira_test.go
@ -145,6 +145,30 @@ func TestClient_NewRequest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClient_NewRawRequest(t *testing.T) {
|
||||
c, err := NewClient(nil, testJIRAInstanceURL)
|
||||
if err != nil {
|
||||
t.Errorf("An error occured. Expected nil. Got %+v.", err)
|
||||
}
|
||||
|
||||
inURL, outURL := "rest/api/2/issue/", testJIRAInstanceURL+"rest/api/2/issue/"
|
||||
|
||||
outBody := `{"key":"MESOS"}` + "\n"
|
||||
inBody := outBody
|
||||
req, _ := c.NewRawRequest("GET", inURL, strings.NewReader(outBody))
|
||||
|
||||
// Test that relative URL was expanded
|
||||
if got, want := req.URL.String(), outURL; got != want {
|
||||
t.Errorf("NewRawRequest(%q) URL is %v, want %v", inURL, got, want)
|
||||
}
|
||||
|
||||
// Test that body was JSON encoded
|
||||
body, _ := ioutil.ReadAll(req.Body)
|
||||
if got, want := string(body), outBody; got != want {
|
||||
t.Errorf("NewRawRequest(%v) Body is %v, want %v", inBody, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func testURLParseError(t *testing.T, err error) {
|
||||
if err == nil {
|
||||
t.Errorf("Expected error to be returned")
|
||||
|
Loading…
Reference in New Issue
Block a user