mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-04-19 12:02:20 +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) {
|
func testURLParseError(t *testing.T, err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("Expected error to be returned")
|
t.Errorf("Expected error to be returned")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user