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 struct tag for varset relationship #521

Merged
merged 2 commits into from Sep 6, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@
# Unreleased

## Bug Fixes
* Fixes null value returned in variable set relationship in `VariableSetVariable` by @sebasslash [#521](https://github.com/hashicorp/go-tfe/pull/521)

# v1.9.0

## Enhancements
Expand Down
2 changes: 1 addition & 1 deletion variable_set_variable.go
Expand Up @@ -49,7 +49,7 @@ type VariableSetVariable struct {
Sensitive bool `jsonapi:"attr,sensitive"`

// Relations
VariableSet *VariableSet `jsonapi:"relation,configurable"`
VariableSet *VariableSet `jsonapi:"relation,varset"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are varset.data.id and varset.data.type being exposed?

Screen Shot 2022-08-30 at 5 27 48 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! The relationship is automatically included in the response body.

}

type VariableSetVariableListOptions struct {
Expand Down
8 changes: 5 additions & 3 deletions variable_set_variable_test.go
Expand Up @@ -34,12 +34,14 @@ func TestVariableSetVariablesList(t *testing.T) {
t.Run("without list options", func(t *testing.T) {
vl, err := client.VariableSetVariables.List(ctx, vsTest.ID, nil)
require.NoError(t, err)
require.NotEmpty(t, vl.Items)
assert.Contains(t, vl.Items, vTest1)
assert.Contains(t, vl.Items, vTest2)

t.Skip("paging not supported yet in API")
assert.Equal(t, 1, vl.CurrentPage)
assert.Equal(t, 2, vl.TotalCount)
t.Run("variable set relationship is deserialized", func(t *testing.T) {
require.NotNil(t, vl.Items[0].VariableSet)
assert.Equal(t, vsTest.ID, vl.Items[0].VariableSet.ID)
})
})

t.Run("with list options", func(t *testing.T) {
Expand Down