Skip to content

Commit 42a4b5f

Browse files
committed
fix: allow tests with premium entitlement orgs
1 parent e66e065 commit 42a4b5f

File tree

3 files changed

+47
-22
lines changed

3 files changed

+47
-22
lines changed

internal/provider/helper_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ func createBusinessOrganization(t *testing.T, client *tfe.Client) (*tfe.Organiza
6666
return org, orgCleanup
6767
}
6868

69+
func createPlusOrganization(t *testing.T, client *tfe.Client) (*tfe.Organization, func()) {
70+
org, orgCleanup := createOrganization(t, client, tfe.OrganizationCreateOptions{
71+
Name: tfe.String("tst-" + randomString(t)),
72+
Email: tfe.String(fmt.Sprintf("%[email protected]", randomString(t))),
73+
})
74+
75+
newSubscriptionUpdater(org).WithPlusEntitlementPlan().Update(t)
76+
77+
return org, orgCleanup
78+
}
79+
6980
func createTrialOrganization(t *testing.T, client *tfe.Client) (*tfe.Organization, func()) {
7081
org, orgCleanup := createOrganization(t, client, tfe.OrganizationCreateOptions{
7182
Name: tfe.String("tst-" + randomString(t)),

internal/provider/resource_tfe_team_notification_configuration_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestAccTFETeamNotificationConfiguration_basic(t *testing.T) {
2020
t.Fatal(err)
2121
}
2222

23-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
23+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
2424
t.Cleanup(cleanupOrg)
2525

2626
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -58,7 +58,7 @@ func TestAccTFETeamNotificationConfiguration_emailUserIDs(t *testing.T) {
5858
t.Fatal(err)
5959
}
6060

61-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
61+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
6262
t.Cleanup(cleanupOrg)
6363

6464
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -96,7 +96,7 @@ func TestAccTFETeamNotificationConfiguration_update(t *testing.T) {
9696
t.Fatal(err)
9797
}
9898

99-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
99+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
100100
t.Cleanup(cleanupOrg)
101101

102102
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -156,7 +156,7 @@ func TestAccTFETeamNotificationConfiguration_updateEmailUserIDs(t *testing.T) {
156156
t.Fatal(err)
157157
}
158158

159-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
159+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
160160
t.Cleanup(cleanupOrg)
161161

162162
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -214,7 +214,7 @@ func TestAccTFETeamNotificationConfiguration_validateSchemaAttributesEmail(t *te
214214
t.Fatal(err)
215215
}
216216

217-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
217+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
218218
t.Cleanup(cleanupOrg)
219219

220220
resource.Test(t, resource.TestCase{
@@ -239,7 +239,7 @@ func TestAccTFETeamNotificationConfiguration_validateSchemaAttributesGeneric(t *
239239
t.Fatal(err)
240240
}
241241

242-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
242+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
243243
t.Cleanup(cleanupOrg)
244244

245245
resource.Test(t, resource.TestCase{
@@ -268,7 +268,7 @@ func TestAccTFETeamNotificationConfiguration_validateSchemaAttributesSlack(t *te
268268
t.Fatal(err)
269269
}
270270

271-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
271+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
272272
t.Cleanup(cleanupOrg)
273273

274274
resource.Test(t, resource.TestCase{
@@ -301,7 +301,7 @@ func TestAccTFETeamNotificationConfiguration_validateSchemaAttributesMicrosoftTe
301301
t.Fatal(err)
302302
}
303303

304-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
304+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
305305
t.Cleanup(cleanupOrg)
306306

307307
resource.Test(t, resource.TestCase{
@@ -334,7 +334,7 @@ func TestAccTFETeamNotificationConfiguration_validateSchemaAttributesBadDestinat
334334
t.Fatal(err)
335335
}
336336

337-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
337+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
338338
t.Cleanup(cleanupOrg)
339339

340340
resource.Test(t, resource.TestCase{
@@ -355,7 +355,7 @@ func TestAccTFETeamNotificationConfiguration_updateValidateSchemaAttributesEmail
355355
t.Fatal(err)
356356
}
357357

358-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
358+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
359359
t.Cleanup(cleanupOrg)
360360

361361
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -404,7 +404,7 @@ func TestAccTFETeamNotificationConfiguration_updateValidateSchemaAttributesGener
404404
t.Fatal(err)
405405
}
406406

407-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
407+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
408408
t.Cleanup(cleanupOrg)
409409

410410
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -457,7 +457,7 @@ func TestAccTFETeamNotificationConfiguration_updateValidateSchemaAttributesSlack
457457
t.Fatal(err)
458458
}
459459

460-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
460+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
461461
t.Cleanup(cleanupOrg)
462462

463463
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -514,7 +514,7 @@ func TestAccTFETeamNotificationConfiguration_updateValidateSchemaAttributesMicro
514514
t.Fatal(err)
515515
}
516516

517-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
517+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
518518
t.Cleanup(cleanupOrg)
519519

520520
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -567,7 +567,7 @@ func TestAccTFETeamNotificationConfiguration_duplicateTriggers(t *testing.T) {
567567
t.Fatal(err)
568568
}
569569

570-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
570+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
571571
t.Cleanup(cleanupOrg)
572572

573573
notificationConfiguration := &tfe.NotificationConfiguration{}
@@ -605,7 +605,7 @@ func TestAccTFETeamNotificationConfigurationImport_basic(t *testing.T) {
605605
t.Fatal(err)
606606
}
607607

608-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
608+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
609609
t.Cleanup(cleanupOrg)
610610

611611
resource.Test(t, resource.TestCase{
@@ -633,7 +633,7 @@ func TestAccTFETeamNotificationConfigurationImport_emailUserIDs(t *testing.T) {
633633
t.Fatal(err)
634634
}
635635

636-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
636+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
637637
t.Cleanup(cleanupOrg)
638638

639639
resource.Test(t, resource.TestCase{
@@ -661,7 +661,7 @@ func TestAccTFETeamNotificationConfigurationImport_emptyEmailUserIDs(t *testing.
661661
t.Fatal(err)
662662
}
663663

664-
org, cleanupOrg := createBusinessOrganization(t, tfeClient)
664+
org, cleanupOrg := createPlusOrganization(t, tfeClient)
665665
t.Cleanup(cleanupOrg)
666666

667667
resource.Test(t, resource.TestCase{

internal/provider/subscription_updater_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ type featureSetListOptions struct {
2727
}
2828

2929
type updateFeatureSetOptions struct {
30-
Type string `jsonapi:"primary,subscription"`
31-
RunsCeiling *int `jsonapi:"attr,runs-ceiling,omitempty"`
32-
ContractStartAt *time.Time `jsonapi:"attr,contract-start-at,iso8601,omitempty"`
33-
ContractUserLimit *int `jsonapi:"attr,contract-user-limit,omitempty"`
34-
ContractApplyLimit *int `jsonapi:"attr,contract-apply-limit,omitempty"`
30+
Type string `jsonapi:"primary,subscription"`
31+
RunsCeiling *int `jsonapi:"attr,runs-ceiling,omitempty"`
32+
ContractStartAt *time.Time `jsonapi:"attr,contract-start-at,iso8601,omitempty"`
33+
ContractUserLimit *int `jsonapi:"attr,contract-user-limit,omitempty"`
34+
ContractApplyLimit *int `jsonapi:"attr,contract-apply-limit,omitempty"`
35+
ContractManagedResourcesLimit *int `jsonapi:"attr,contract-managed-resources-limit,omitempty"`
3536

3637
FeatureSet *featureSet `jsonapi:"relation,feature-set"`
3738
}
@@ -49,6 +50,19 @@ func newSubscriptionUpdater(organization *tfe.Organization) *organizationSubscri
4950
}
5051
}
5152

53+
func (b *organizationSubscriptionUpdater) WithPlusEntitlementPlan() *organizationSubscriptionUpdater {
54+
b.planName = "Plus (entitlement)"
55+
56+
start := time.Now()
57+
ceiling := 1
58+
managedResourcesLimit := 1000
59+
60+
b.updateOpts.ContractStartAt = &start
61+
b.updateOpts.RunsCeiling = &ceiling
62+
b.updateOpts.ContractManagedResourcesLimit = &managedResourcesLimit
63+
return b
64+
}
65+
5266
func (b *organizationSubscriptionUpdater) WithBusinessPlan() *organizationSubscriptionUpdater {
5367
b.planName = "Business"
5468

0 commit comments

Comments
 (0)