fix the session_test

It was broken.

Change-Id: I03a51a6cc30c3bcc6d6ae778973b7fe374fe3272
This commit is contained in:
arkxu 2016-04-23 00:04:50 -07:00
parent 1bc5f497bb
commit 452642dade
2 changed files with 10 additions and 4 deletions

View File

@ -89,10 +89,10 @@ func DoAuthRequest(authopts AuthOpts) (AuthRef, error) {
rbody, err := ioutil.ReadAll(resp.Body) rbody, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, errors.New("aaa") return nil, errors.New("error reading response body")
} }
if err = json.Unmarshal(rbody, &auth); err != nil { if err = json.Unmarshal(rbody, &auth); err != nil {
return nil, errors.New("bbb") return nil, errors.New("error unmarshalling response body")
} }
return auth, nil return auth, nil

View File

@ -17,6 +17,7 @@ package openstack_test
import ( import (
"encoding/json" "encoding/json"
"io/ioutil"
"net/http" "net/http"
"testing" "testing"
@ -40,7 +41,7 @@ func TestSessionGet(t *testing.T) {
expected := TestStruct{ID: "id1", Name: "Chris"} expected := TestStruct{ID: "id1", Name: "Chris"}
actual := TestStruct{} actual := TestStruct{}
s, _ := openstack.NewSession(nil, "", nil) s, _ := openstack.NewSession(nil, nil, nil)
var headers http.Header = http.Header{} var headers http.Header = http.Header{}
headers.Set("X-Auth-Token", tokn) headers.Set("X-Auth-Token", tokn)
headers.Set("Accept", "application/json") headers.Set("Accept", "application/json")
@ -51,7 +52,12 @@ func TestSessionGet(t *testing.T) {
} }
testUtil.IsNil(t, err) testUtil.IsNil(t, err)
if err = json.Unmarshal(resp.Body, &actual); err != nil { rbody, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Error(err)
}
if err = json.Unmarshal(rbody, &actual); err != nil {
t.Error(err) t.Error(err)
} }