-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathstack_configuration_summary_integration_test.go
More file actions
79 lines (64 loc) · 2.05 KB
/
stack_configuration_summary_integration_test.go
File metadata and controls
79 lines (64 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright IBM Corp. 2018, 2025
// SPDX-License-Identifier: MPL-2.0
package tfe
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestStackConfigurationSummaryList(t *testing.T) {
t.Parallel()
client := testClient(t)
ctx := context.Background()
orgTest, orgTestCleanup := createOrganization(t, client)
t.Cleanup(orgTestCleanup)
oauthClient, cleanup := createOAuthClient(t, client, orgTest, nil)
t.Cleanup(cleanup)
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
Name: "aa-test-stack",
VCSRepo: &StackVCSRepoOptions{
Identifier: stackVCSRepoIdentifier(t),
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
},
Project: &Project{
ID: orgTest.DefaultProject.ID,
},
})
require.NoError(t, err)
require.NotNil(t, stack)
stack2, err := client.Stacks.Create(ctx, StackCreateOptions{
Name: "bb-test-stack",
VCSRepo: &StackVCSRepoOptions{
Identifier: stackVCSRepoIdentifier(t),
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
},
Project: &Project{
ID: orgTest.DefaultProject.ID,
},
})
require.NoError(t, err)
require.NotNil(t, stack2)
// Trigger first stack configuration by updating configuration
_, err = client.Stacks.FetchLatestFromVcs(ctx, stack2.ID)
require.NoError(t, err)
// Wait a bit and trigger second stack configuration
time.Sleep(2 * time.Second)
_, err = client.Stacks.FetchLatestFromVcs(ctx, stack2.ID)
require.NoError(t, err)
t.Run("Successful empty list", func(t *testing.T) {
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack.ID, nil)
require.NoError(t, err)
assert.Len(t, stackConfigSummaryList.Items, 0)
})
t.Run("Successful multiple config summary list", func(t *testing.T) {
stackConfigSummaryList, err := client.StackConfigurationSummaries.List(ctx, stack2.ID, nil)
require.NoError(t, err)
assert.Len(t, stackConfigSummaryList.Items, 2)
})
t.Run("Unsuccessful list", func(t *testing.T) {
_, err := client.StackConfigurationSummaries.List(ctx, "", nil)
require.Error(t, err)
})
}