Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle Go SDK 204 no responses correctly #1193

Merged
merged 3 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions go/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,66 @@ func TestIntegrationGoSDK(t *testing.T) {
}
})

t.Run("CRUD User Attribute Group Value", func(t *testing.T) {
name := "foo"
group, err := sdk.CreateGroup(v4.WriteGroup{
Name: &name,
}, "", nil)
if err != nil {
t.Errorf("CreateGroup() failed. error=%v", err)
}

groupId := group.Id
group, err = sdk.Group(*groupId, "", nil)
if err != nil {
t.Errorf("Group() failed. error=%v", err)
}

attributeName := "bar"
attributeLabel := "bar"
attributeType := "string"
ua, err := sdk.CreateUserAttribute(v4.WriteUserAttribute{
Name: attributeName,
Label: attributeLabel,
Type: attributeType,
}, "", nil)
if err != nil {
t.Errorf("CreateUserAttribute failed. error=%v", err)
}

uaId := ua.Id
ua, err = sdk.UserAttribute(*uaId, "", nil)
if err != nil {
t.Errorf("UserAttribute() failed. error=%v", err)
}

value := "baz"
_, err = sdk.UpdateUserAttributeGroupValue(*groupId, *uaId, v4.UserAttributeGroupValue{
GroupId: groupId,
UserAttributeId: uaId,
Value: &value,
}, nil)
if err != nil {
t.Errorf("UpdateUserAttributeGroupValue() failed. error=%v", err)
}

err = sdk.DeleteUserAttributeGroupValue(*groupId, *uaId, nil)
if err != nil {
t.Errorf("DeleteUserAttributeGroupValue() failed. error=%v", err)
}

_, err = sdk.DeleteUserAttribute(*uaId, nil)
if err != nil {
t.Errorf("DeleteUserAttribute() failed. error=%v", err)
}

_, err = sdk.DeleteGroup(*groupId, nil)
if err != nil {
t.Errorf("DeleteGroup() failed. error=%v", err)
}

})

t.Run("Me()", func(t *testing.T) {
user, err := sdk.Me("", nil)

Expand Down
4 changes: 4 additions & 0 deletions go/rtl/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ func (s *AuthSession) Do(result interface{}, method, ver, path string, reqPars m
return fmt.Errorf("response error. status=%s. error=%s", res.Status, string(b))
}

if res.StatusCode == 204 { // 204 No Content. DELETE endpoints returns response with no body
return nil
}

// TODO: Make parsing content-type aware. Requires change to go model generation to use interface{} for all union types.
// Github Issue: https://github.com/looker-open-source/sdk-codegen/issues/1022
switch v := result.(type) {
Expand Down