Skip to content

Commit e15e690

Browse files
committed
chore: incorporate review feedback
1 parent e801b42 commit e15e690

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

stack_deployment_runs.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type StackDeploymentRuns interface {
1515
// List returns a list of stack deployment runs for a given deployment group.
1616
List(ctx context.Context, deploymentGroupID string, options *StackDeploymentRunListOptions) (*StackDeploymentRunList, error)
1717
Read(ctx context.Context, stackDeploymentRunID string) (*StackDeploymentRun, error)
18+
ReadWithOptions(ctx context.Context, stackDeploymentRunID string, options *StackDeploymentRunReadOptions) (*StackDeploymentRun, error)
1819
ApproveAllPlans(ctx context.Context, deploymentRunID string) error
1920
Cancel(ctx context.Context, stackDeploymentRunID string) error
2021
}
@@ -43,21 +44,20 @@ const (
4344
SDRDeploymentGroup SDRIncludeOpt = "stack-deployment-group"
4445
)
4546

46-
type StackDeploymentRunReadOptions struct {
47-
// Optional: A list of relations to include.
48-
Include []SDRIncludeOpt `url:"include,omitempty"`
49-
}
50-
5147
// StackDeploymentRunList represents a list of stack deployment runs.
5248
type StackDeploymentRunList struct {
5349
*Pagination
5450
Items []*StackDeploymentRun
5551
}
5652

53+
type StackDeploymentRunReadOptions struct {
54+
// Optional: A list of relations to include.
55+
Include []SDRIncludeOpt `url:"include,omitempty"`
56+
}
57+
5758
// StackDeploymentRunListOptions represents the options for listing stack deployment runs.
5859
type StackDeploymentRunListOptions struct {
5960
ListOptions
60-
6161
// Optional: A list of relations to include.
6262
Include []SDRIncludeOpt `url:"include,omitempty"`
6363
}

stack_deployment_runs_integration_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ func TestStackDeploymentRunsList(t *testing.T) {
7272
require.NoError(t, err)
7373
assert.NotNil(t, runList)
7474
})
75+
76+
t.Run("With include option", func(t *testing.T) {
77+
t.Parallel()
78+
79+
runList, err := client.StackDeploymentRuns.List(ctx, deploymentGroupID, &StackDeploymentRunListOptions{
80+
Include: []SDRIncludeOpt{"stack-deployment-group"},
81+
})
82+
assert.NoError(t, err)
83+
assert.NotNil(t, runList)
84+
for _, run := range runList.Items {
85+
assert.NotNil(t, run.StackDeploymentGroup.ID)
86+
}
87+
})
88+
89+
t.Run("With invalid include option", func(t *testing.T) {
90+
t.Parallel()
91+
92+
_, err := client.StackDeploymentRuns.List(ctx, deploymentGroupID, &StackDeploymentRunListOptions{
93+
Include: []SDRIncludeOpt{"invalid-option"},
94+
})
95+
assert.Error(t, err)
96+
})
7597
}
7698

7799
func TestStackDeploymentRunsRead(t *testing.T) {
@@ -127,6 +149,22 @@ func TestStackDeploymentRunsRead(t *testing.T) {
127149
_, err := client.StackDeploymentRuns.Read(ctx, "")
128150
assert.Error(t, err)
129151
})
152+
153+
t.Run("Read with options", func(t *testing.T) {
154+
run, err := client.StackDeploymentRuns.ReadWithOptions(ctx, sdr.ID, &StackDeploymentRunReadOptions{
155+
Include: []SDRIncludeOpt{"stack-deployment-group"},
156+
})
157+
assert.NoError(t, err)
158+
assert.NotNil(t, run)
159+
assert.NotNil(t, run.StackDeploymentGroup.ID)
160+
})
161+
162+
t.Run("Read with invalid options", func(t *testing.T) {
163+
_, err := client.StackDeploymentRuns.ReadWithOptions(ctx, sdr.ID, &StackDeploymentRunReadOptions{
164+
Include: []SDRIncludeOpt{"invalid-option"},
165+
})
166+
assert.Error(t, err)
167+
})
130168
}
131169

132170
func TestStackDeploymentRunsApproveAllPlans(t *testing.T) {

stack_deployment_steps_integration_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ func TestStackDeploymentStepsList(t *testing.T) {
2828
Project: orgTest.DefaultProject,
2929
Name: "test-stack",
3030
VCSRepo: &StackVCSRepoOptions{
31-
Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID,
32-
Branch: "main",
31+
Identifier: "hashicorp-guides/pet-nulls-stack",
32+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
33+
Branch: "main",
3334
},
3435
})
3536
require.NoError(t, err)
@@ -117,8 +118,9 @@ func TestStackDeploymentStepsRead(t *testing.T) {
117118
Project: orgTest.DefaultProject,
118119
Name: "test-stack",
119120
VCSRepo: &StackVCSRepoOptions{
120-
Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID,
121-
Branch: "main",
121+
Identifier: "hashicorp-guides/pet-nulls-stack",
122+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
123+
Branch: "main",
122124
},
123125
})
124126
require.NoError(t, err)
@@ -178,8 +180,9 @@ func TestStackDeploymentStepsAdvance(t *testing.T) {
178180
Project: orgTest.DefaultProject,
179181
Name: "testing-stack",
180182
VCSRepo: &StackVCSRepoOptions{
181-
Identifier: "hashicorp-guides/pet-nulls-stack", OAuthTokenID: oauthClient.OAuthTokens[0].ID,
182-
Branch: "main",
183+
Identifier: "hashicorp-guides/pet-nulls-stack",
184+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
185+
Branch: "main",
183186
},
184187
})
185188
require.NoError(t, err)

0 commit comments

Comments
 (0)