Skip to content

Commit 4c156e4

Browse files
formatting and changelog to be updated
1 parent a17a7e0 commit 4c156e4

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Unreleased
22
* Add support for HCP Terraform `/api/v2/workspaces/{external_id}/all-vars` API endpoint to fetch the list of all variables available to a workspace (include inherited variables from varsets) by @debrin-hc [#1105](https://github.com/hashicorp/go-tfe/pull/1105)
33

4+
* Adds BETA support for listing `StackDeploymentGroups`, which is EXPERIMENTAL, SUBJECT TO CHANGE, and may not be available to all users by @hwatkins05-hashicorp []()
5+
46
# v1.82.0
57

68
## Enhancements

stack_deployment_groups.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ func (s stackDeploymentGroups) List(ctx context.Context, stackConfigID string, o
7676
}
7777

7878
return sdgl, nil
79-
}
79+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package tfe
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestStackDeploymentGroupsList(t *testing.T) {
12+
skipUnlessBeta(t)
13+
client := testClient(t)
14+
ctx := context.Background()
15+
16+
orgTest, orgTestCleanup := createOrganization(t, client)
17+
t.Cleanup(orgTestCleanup)
18+
19+
oauthClient, cleanup := createOAuthClient(t, client, orgTest, nil)
20+
t.Cleanup(cleanup)
21+
22+
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
23+
Name: "test-stack",
24+
VCSRepo: &StackVCSRepoOptions{
25+
Identifier: "hwatkins05-hashicorp/pet-nulls-stack",
26+
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
27+
},
28+
Project: &Project{
29+
ID: orgTest.DefaultProject.ID,
30+
},
31+
})
32+
33+
require.NoError(t, err)
34+
require.NotNil(t, stack)
35+
36+
stackUpdated, err := client.Stacks.UpdateConfiguration(ctx, stack.ID)
37+
require.NoError(t, err)
38+
require.NotNil(t, stackUpdated)
39+
require.NotEmpty(t, stackUpdated.LatestStackConfiguration.ID)
40+
41+
stackUpdated = pollStackDeployments(t, ctx, client, stackUpdated.ID)
42+
require.NotNil(t, stackUpdated.LatestStackConfiguration)
43+
44+
stackUpdated.LatestStackConfiguration, _ = client.StackConfigurations.Read(ctx, stackUpdated.LatestStackConfiguration.ID)
45+
46+
t.Run("with valid stack configuration ID", func(t *testing.T) {
47+
//t.Parallel()
48+
sdgl, err := client.StackDeploymentGroups.List(ctx, stackUpdated.LatestStackConfiguration.ID, nil)
49+
require.NoError(t, err)
50+
require.NotNil(t, sdgl)
51+
52+
for _, item := range sdgl.Items {
53+
assert.NotNil(t, item.Id)
54+
assert.NotEmpty(t, item.Name)
55+
assert.NotEmpty(t, item.Status)
56+
assert.NotNil(t, item.CreatedAt)
57+
assert.NotNil(t, item.UpdatedAt)
58+
assert.NotEmpty(t, item.StackConfigurationId)
59+
assert.GreaterOrEqual(t, item.FailureCount, 0)
60+
}
61+
})
62+
63+
// t.Run("with invalid stack configuration ID", func(t *testing.T) {
64+
// //t.Parallel()
65+
// _, err := client.StackDeploymentGroups.List(ctx, "", nil)
66+
// require.Error(t, err)
67+
// })
68+
69+
// t.Run("List with pagination", func(t *testing.T) {
70+
// t.Parallel()
71+
// options := &StackDeploymentGroupListOptions{
72+
// ListOptions: ListOptions{
73+
// PageNumber: 2,
74+
// PageSize: 2,
75+
// },
76+
// }
77+
// sdgl, err := client.StackDeploymentGroups.List(ctx, stackUpdated.LatestStackConfiguration.ID, options)
78+
// require.NoError(t, err)
79+
// require.NotNil(t, sdgl)
80+
// require.Len(t, sdgl.Items, 0)
81+
// })
82+
}

0 commit comments

Comments
 (0)