Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

Commit 0dfb97d

Browse files
author
Samuel Ortiz
committed
imageservice: Fix members unit tests
We need to: 1) Specify that our returned payload is a JSON one 2) Return a dumb payload when returning a POST error or else client.Request() tries to unmarshal a nil payload. We will send a further path to fix client.Request() to not expect a POST response payload for certain status codes. Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 7544556 commit 0dfb97d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

openstack/imageservice/v2/members/fixtures.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func HandleCreateImageMemberInvalidVisibility(t *testing.T) {
3838

3939
th.TestJSONRequest(t, r, `{"member": "8989447062e04a818baf9e073fd04fa7"}`)
4040
w.WriteHeader(http.StatusForbidden)
41+
w.Header().Add("Content-Type", "application/json")
42+
fmt.Fprintf(w, `{"members":[]}`)
4143
})
4244

4345
}
@@ -51,6 +53,8 @@ func HandleCreateImageMemberConflict(t *testing.T) {
5153
th.TestJSONRequest(t, r, `{"member": "8989447062e04a818baf9e073fd04fa7"}`)
5254

5355
w.WriteHeader(http.StatusConflict)
56+
w.Header().Add("Content-Type", "application/json")
57+
fmt.Fprintf(w, `{"members":[]}`)
5458
})
5559
}
5660

@@ -60,7 +64,7 @@ func HandleImageMemberList(t *testing.T) {
6064
th.TestMethod(t, r, "GET")
6165
th.TestHeader(t, r, "X-Auth-Token", fakeclient.TokenID)
6266

63-
w.WriteHeader(http.StatusOK)
67+
w.Header().Add("Content-Type", "application/json")
6468
fmt.Fprintf(w, `{
6569
"members": [
6670
{
@@ -91,7 +95,7 @@ func HandleImageMemberEmptyList(t *testing.T) {
9195
th.TestMethod(t, r, "GET")
9296
th.TestHeader(t, r, "X-Auth-Token", fakeclient.TokenID)
9397

94-
w.WriteHeader(http.StatusOK)
98+
w.Header().Add("Content-Type", "application/json")
9599
fmt.Fprintf(w, `{
96100
"members": [],
97101
"schema": "/v2/schemas/members"

0 commit comments

Comments
 (0)