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
expose additional fields in state versions struct #484
Changes from all commits
83b2c36
fce39e6
19d2d11
db4b027
5396ac1
83bc01b
816b6fc
559d6a0
7f8fd45
6de864a
5c539f0
16449f1
5f2d2c1
e1bdc12
f9669b1
fee64a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,15 @@ func TestStateVersionsList(t *testing.T) { | |
ctx := context.Background() | ||
|
||
orgTest, orgTestCleanup := createOrganization(t, client) | ||
defer orgTestCleanup() | ||
t.Cleanup(orgTestCleanup) | ||
|
||
wTest, wTestCleanup := createWorkspace(t, client, orgTest) | ||
defer wTestCleanup() | ||
t.Cleanup(wTestCleanup) | ||
|
||
svTest1, svTestCleanup1 := createStateVersion(t, client, 0, wTest) | ||
defer svTestCleanup1() | ||
t.Cleanup(svTestCleanup1) | ||
svTest2, svTestCleanup2 := createStateVersion(t, client, 1, wTest) | ||
defer svTestCleanup2() | ||
t.Cleanup(svTestCleanup2) | ||
|
||
t.Run("without StateVersionListOptions", func(t *testing.T) { | ||
svl, err := client.StateVersions.List(ctx, nil) | ||
|
@@ -115,7 +115,7 @@ func TestStateVersionsCreate(t *testing.T) { | |
ctx := context.Background() | ||
|
||
wTest, wTestCleanup := createWorkspace(t, client, nil) | ||
defer wTestCleanup() | ||
t.Cleanup(wTestCleanup) | ||
|
||
state, err := ioutil.ReadFile("test-fixtures/state-version/terraform.tfstate") | ||
if err != nil { | ||
|
@@ -248,7 +248,7 @@ func TestStateVersionsCreate(t *testing.T) { | |
t.Skip("This can only be tested with the run specific token") | ||
|
||
rTest, rTestCleanup := createRun(t, client, wTest) | ||
defer rTestCleanup() | ||
t.Cleanup(rTestCleanup) | ||
|
||
ctx := context.Background() | ||
sv, err := client.StateVersions.Create(ctx, wTest.ID, StateVersionCreateOptions{ | ||
|
@@ -316,7 +316,7 @@ func TestStateVersionsRead(t *testing.T) { | |
ctx := context.Background() | ||
|
||
svTest, svTestCleanup := createStateVersion(t, client, 0, nil) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
t.Run("when the state version exists", func(t *testing.T) { | ||
sv, err := client.StateVersions.Read(ctx, svTest.ID) | ||
|
@@ -333,6 +333,12 @@ func TestStateVersionsRead(t *testing.T) { | |
sv.Outputs = nil | ||
|
||
assert.Equal(t, svTest, sv) | ||
assert.NotEmpty(t, svTest, svTest.ResourcesProcessed) | ||
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. This is what I meant! Thanks. I am slightly worried that some of these will indeed be empty if the backend hasn't yet processed the state. The way to fix this would be to retry while ResourcesProcessed was false. Or we could just wait and see if it flakes! 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. @brandonc Wouldn't it stand true that if ResourcesProcessed were false, it would still validate on NotEmpty? Like regardless of which bool, it will still always contain a value? 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. Ah, the attr returning 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.
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. Could this example in the State Version API docs be incorrect? The response has
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. Yes, it is. If resources_processed is false, you would expect the resources key to be empty. |
||
assert.NotEmpty(t, svTest, svTest.StateVersion) | ||
assert.NotEmpty(t, svTest, svTest.TerraformVersion) | ||
assert.NotEmpty(t, svTest, svTest.Modules) | ||
assert.NotEmpty(t, svTest, svTest.Providers) | ||
assert.NotEmpty(t, svTest, svTest.Resources) | ||
}) | ||
|
||
t.Run("when the state version does not exist", func(t *testing.T) { | ||
|
@@ -353,7 +359,7 @@ func TestStateVersionsReadWithOptions(t *testing.T) { | |
ctx := context.Background() | ||
|
||
svTest, svTestCleanup := createStateVersion(t, client, 0, nil) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
// give TFC some time to process the statefile and extract the outputs. | ||
waitForSVOutputs(t, client, svTest.ID) | ||
|
@@ -375,13 +381,13 @@ func TestStateVersionsCurrent(t *testing.T) { | |
ctx := context.Background() | ||
|
||
wTest1, wTest1Cleanup := createWorkspace(t, client, nil) | ||
defer wTest1Cleanup() | ||
t.Cleanup(wTest1Cleanup) | ||
|
||
wTest2, wTest2Cleanup := createWorkspace(t, client, nil) | ||
defer wTest2Cleanup() | ||
t.Cleanup(wTest2Cleanup) | ||
|
||
svTest, svTestCleanup := createStateVersion(t, client, 0, wTest1) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
t.Run("when a state version exists", func(t *testing.T) { | ||
sv, err := client.StateVersions.ReadCurrent(ctx, wTest1.ID) | ||
|
@@ -418,10 +424,10 @@ func TestStateVersionsCurrentWithOptions(t *testing.T) { | |
ctx := context.Background() | ||
|
||
wTest1, wTest1Cleanup := createWorkspace(t, client, nil) | ||
defer wTest1Cleanup() | ||
t.Cleanup(wTest1Cleanup) | ||
|
||
svTest, svTestCleanup := createStateVersion(t, client, 0, wTest1) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
// give TFC some time to process the statefile and extract the outputs. | ||
waitForSVOutputs(t, client, svTest.ID) | ||
|
@@ -443,7 +449,7 @@ func TestStateVersionsDownload(t *testing.T) { | |
ctx := context.Background() | ||
|
||
svTest, svTestCleanup := createStateVersion(t, client, 0, nil) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
stateTest, err := ioutil.ReadFile("test-fixtures/state-version/terraform.tfstate") | ||
require.NoError(t, err) | ||
|
@@ -475,10 +481,10 @@ func TestStateVersionOutputs(t *testing.T) { | |
ctx := context.Background() | ||
|
||
wTest1, wTest1Cleanup := createWorkspace(t, client, nil) | ||
defer wTest1Cleanup() | ||
t.Cleanup(wTest1Cleanup) | ||
|
||
sv, svTestCleanup := createStateVersion(t, client, 0, wTest1) | ||
defer svTestCleanup() | ||
t.Cleanup(svTestCleanup) | ||
|
||
// give TFC some time to process the statefile and extract the outputs. | ||
waitForSVOutputs(t, client, sv.ID) | ||
|
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.
Can these be tested?
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.
@brandonc I can confirm the new attributes are exposed in the response body. Is that sufficient? Do you have any suggestions?