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
Adds StateVersionOutputs ReadCurrent #370
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7647755
feat: add support for workspaces current-state-version-output
brandonc b65731e
fix: error when output ID is invalid
brandonc bc3385b
Update state_version_output_mocks.go
brandonc 0aa45b9
test that sensitive values are null
brandonc e97759b
test fix: don't compare values because output may be sensitive
brandonc File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const waitForStateVersionOutputs = 700 * time.Millisecond | ||
const waitForStateVersionOutputs = 1000 * time.Millisecond | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why 1000 instead of 700? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My tests didn't pass locally with the old timing. |
||
|
||
func TestStateVersionOutputsRead(t *testing.T) { | ||
client := testClient(t) | ||
|
@@ -38,19 +38,29 @@ func TestStateVersionOutputsRead(t *testing.T) { | |
|
||
output := sv.Outputs[0] | ||
|
||
t.Run("when a state output exists", func(t *testing.T) { | ||
so, err := client.StateVersionOutputs.Read(ctx, output.ID) | ||
require.NoError(t, err) | ||
t.Run("Read by ID", func(t *testing.T) { | ||
t.Run("when a state output exists", func(t *testing.T) { | ||
so, err := client.StateVersionOutputs.Read(ctx, output.ID) | ||
require.NoError(t, err) | ||
|
||
assert.Equal(t, so.ID, output.ID) | ||
assert.Equal(t, so.Name, output.Name) | ||
assert.Equal(t, so.Value, output.Value) | ||
}) | ||
assert.Equal(t, so.ID, output.ID) | ||
assert.Equal(t, so.Name, output.Name) | ||
assert.Equal(t, so.Value, output.Value) | ||
}) | ||
brandonc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
t.Run("when a state output does not exist", func(t *testing.T) { | ||
so, err := client.StateVersionOutputs.Read(ctx, "wsout-J2zM24JPAAAAAAAA") | ||
assert.Nil(t, so) | ||
assert.Equal(t, ErrResourceNotFound, err) | ||
t.Run("when a state output does not exist", func(t *testing.T) { | ||
so, err := client.StateVersionOutputs.Read(ctx, "wsout-J2zM24JPAAAAAAAA") | ||
assert.Nil(t, so) | ||
assert.Equal(t, ErrResourceNotFound, err) | ||
}) | ||
}) | ||
|
||
t.Run("Read current workspace outputs", func(t *testing.T) { | ||
brandonc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
so, err := client.StateVersionOutputs.ReadCurrent(ctx, wTest1.ID) | ||
|
||
assert.Nil(t, err) | ||
assert.NotNil(t, so) | ||
|
||
assert.Greater(t, len(so.Items), 0, "workspace state version outputs were empty") | ||
}) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we have this precedence for ReadCurrent and ReadCurrentwithOptions: https://github.com/hashicorp/go-tfe/blob/main/state_version.go#L33-L36 But if this endpoint won't be adding options in the near future, then we are good.