diff --git a/iam/groups_service.go b/iam/groups_service.go index 016c7362..6fddaf85 100644 --- a/iam/groups_service.go +++ b/iam/groups_service.go @@ -235,15 +235,17 @@ func (g *GroupsService) memberAction(ctx context.Context, group Group, action st var memberResponse map[string]interface{} var resp *Response - internal.TryHTTPCall(ctx, 6, func() (*http.Response, error) { + err = internal.TryHTTPCall(ctx, 6, func() (*http.Response, error) { resp, err = g.client.do(req, &memberResponse) if resp == nil { return nil, err } + if err != nil && err == io.EOF { // EOF is valid + err = nil + } return resp.Response, err }) - - if err != nil && err != io.EOF { // EOF is valid + if err != nil { return memberResponse, resp, err } return memberResponse, resp, nil diff --git a/iam/groups_service_test.go b/iam/groups_service_test.go index 0eee107c..482d19f1 100644 --- a/iam/groups_service_test.go +++ b/iam/groups_service_test.go @@ -251,9 +251,11 @@ func TestAddMembers(t *testing.T) { if resp != nil { assert.Equal(t, http.StatusOK, resp.StatusCode()) } + if !assert.Nil(t, err) { + return + } assert.Len(t, assignedTotal, 28) assert.Nil(t, ok) - assert.Nil(t, err) } func TestRemoveMembers(t *testing.T) { @@ -333,9 +335,11 @@ func TestRemoveMembers(t *testing.T) { assert.Equal(t, http.StatusOK, resp.StatusCode()) ok, resp, err = client.Groups.RemoveMembers(context.Background(), group, "foo") + if !assert.NotNil(t, err) { + return + } assert.NotNil(t, resp) assert.Nil(t, ok) - assert.NotNil(t, err) } func TestRemoveRole(t *testing.T) { @@ -393,9 +397,10 @@ func TestRemoveRole(t *testing.T) { group.ID = groupID role.ID = roleID ok, resp, err := client.Groups.RemoveRole(group, role) + if !assert.Nil(t, err) { + } assert.NotNil(t, resp) assert.True(t, ok) - assert.Nil(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode()) }