1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2024-11-24 08:22:42 +02:00

Add test for NewRawRequest

This commit is contained in:
gm42 2016-10-10 12:54:45 +02:00
parent dad2a7214f
commit 16619653d8

View File

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