forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_plan_integration_test.go
68 lines (51 loc) · 1.81 KB
/
stack_plan_integration_test.go
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
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tfe
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestStackPlanList(t *testing.T) {
skipUnlessBeta(t)
client := testClient(t)
ctx := context.Background()
orgTest, orgTestCleanup := createOrganization(t, client)
t.Cleanup(orgTestCleanup)
_, err := client.Projects.Create(ctx, orgTest.Name, ProjectCreateOptions{
Name: "test-project-2",
})
require.NoError(t, err)
oauthClient, cleanup := createOAuthClient(t, client, orgTest, nil)
t.Cleanup(cleanup)
stack, err := client.Stacks.Create(ctx, StackCreateOptions{
Name: "aa-test-stack",
VCSRepo: &StackVCSRepo{
Identifier: "brandonc/pet-nulls-stack",
OAuthTokenID: oauthClient.OAuthTokens[0].ID,
},
Project: &Project{
ID: orgTest.DefaultProject.ID,
},
})
require.NoError(t, err)
stackUpdated, err := client.Stacks.UpdateConfiguration(ctx, stack.ID)
require.NoError(t, err)
stackUpdated = pollStackDeployments(t, ctx, client, stackUpdated.ID)
require.NotNil(t, stackUpdated.LatestStackConfiguration)
planList, err := client.StackPlans.ListByConfiguration(ctx, stackUpdated.LatestStackConfiguration.ID, &StackPlansListOptions{})
require.NoError(t, err)
require.Len(t, planList.Items, 4)
plan, err := client.StackPlans.Read(ctx, planList.Items[0].ID)
require.NoError(t, err)
require.NotNil(t, plan)
jsonSchema, err := client.StackConfigurations.JSONSchemas(ctx, stackUpdated.LatestStackConfiguration.ID)
require.NoError(t, err)
require.NotNil(t, jsonSchema)
planDesc, err := client.StackPlans.PlanDescription(ctx, planList.Items[0].ID)
require.NoError(t, err)
require.NotNil(t, planDesc)
spo, err := client.StackPlanOperations.Read(ctx, stackUpdated.LatestStackConfiguration.ID)
require.NoError(t, err)
require.NotNil(t, spo)
}