Skip to content

Commit

Permalink
Merge pull request #598 from hashicorp/brandon/skipUnless
Browse files Browse the repository at this point in the history
Chore: skipIfBeta is worded as the opposite logic
  • Loading branch information
brandonc committed Dec 1, 2022
2 parents 50db25d + 7e6bf06 commit d2e0e00
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 71 deletions.
10 changes: 5 additions & 5 deletions admin_organization_integration_test.go
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestAdminOrganizations_List(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestAdminOrganizations_List(t *testing.T) {
}

func TestAdminOrganizations_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestAdminOrganizations_Read(t *testing.T) {
}

func TestAdminOrganizations_Delete(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -145,7 +145,7 @@ func TestAdminOrganizations_Delete(t *testing.T) {
}

func TestAdminOrganizations_ModuleConsumers(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -189,7 +189,7 @@ func TestAdminOrganizations_ModuleConsumers(t *testing.T) {
}

func TestAdminOrganizations_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_run_integration_test.go
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestAdminRuns_List(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -146,7 +146,7 @@ func TestAdminRuns_List(t *testing.T) {
}

func TestAdminRuns_ForceCancel(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestAdminRuns_ForceCancel(t *testing.T) {
}

func TestAdminRuns_AdminRunsListOptions_valid(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

t.Run("has valid status", func(t *testing.T) {
opts := AdminRunsListOptions{
Expand Down
4 changes: 2 additions & 2 deletions admin_setting_cost_estimation_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_CostEstimation_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -21,7 +21,7 @@ func TestAdminSettings_CostEstimation_Read(t *testing.T) {
}

func TestAdminSettings_CostEstimation_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions admin_setting_customization_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_Customization_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -26,7 +26,7 @@ func TestAdminSettings_Customization_Read(t *testing.T) {
}

func TestAdminSettings_Customization_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions admin_setting_general_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_General_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -35,7 +35,7 @@ func TestAdminSettings_General_Read(t *testing.T) {
}

func TestAdminSettings_General_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_setting_saml_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_SAML_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -37,7 +37,7 @@ func TestAdminSettings_SAML_Read(t *testing.T) {
}

func TestAdminSettings_SAML_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -58,7 +58,7 @@ func TestAdminSettings_SAML_Update(t *testing.T) {
}

func TestAdminSettings_SAML_RevokeIdpCert(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions admin_setting_smtp_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_SMTP_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -27,7 +27,7 @@ func TestAdminSettings_SMTP_Read(t *testing.T) {
}

func TestAdminSettings_SMTP_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_setting_twilio_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminSettings_Twilio_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -24,7 +24,7 @@ func TestAdminSettings_Twilio_Read(t *testing.T) {
}

func TestAdminSettings_Twilio_Update(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -38,7 +38,7 @@ func TestAdminSettings_Twilio_Update(t *testing.T) {
}

func TestAdminSettings_Twilio_Verify(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_terraform_version_integration_test.go
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestAdminTerraformVersions_List(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestAdminTerraformVersions_List(t *testing.T) {
}

func TestAdminTerraformVersions_CreateDelete(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestAdminTerraformVersions_CreateDelete(t *testing.T) {
}

func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_user_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAdminUsers_List(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestAdminUsers_List(t *testing.T) {
}

func TestAdminUsers_Delete(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestAdminUsers_Delete(t *testing.T) {
}

func TestAdminUsers_Disable2FA(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions admin_workspace_integration_test.go
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestAdminWorkspaces_List(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestAdminWorkspaces_List(t *testing.T) {
}

func TestAdminWorkspaces_Read(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestAdminWorkspaces_Read(t *testing.T) {
}

func TestAdminWorkspaces_Delete(t *testing.T) {
skipIfCloud(t)
skipUnlessEnterprise(t)

client := testClient(t)
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions agent_integration_test.go
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestAgentsRead(t *testing.T) {
skipIfNotLinuxAmd64(t)
skipUnlessLinuxAMD64(t)

client := testClient(t)
ctx := context.Background()
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestAgentsRead(t *testing.T) {
}

func TestAgentsList(t *testing.T) {
skipIfNotLinuxAmd64(t)
skipUnlessLinuxAMD64(t)

client := testClient(t)
ctx := context.Background()
Expand Down
6 changes: 3 additions & 3 deletions docs/CONTRIBUTING.md
Expand Up @@ -57,11 +57,11 @@ Beta features, if released, should be clearly commented:
ExampleNewField *bool `jsonapi:"attr,example-new-field,omitempty"`
```

When adding test cases, you can temporarily use the skipIfBeta() test helper to omit beta features from running in CI.
When adding test cases, you can temporarily use the skipUnlessBeta() test helper to omit beta features from running in CI.

```
t.Run("with nested changes trigger", func (t *testing.T) {
skipIfBeta(t)
skipUnlessBeta(t)
options := WorkspaceCreateOptions {
// rest of required fields here
ExampleNewField: Bool(true),
Expand All @@ -70,7 +70,7 @@ t.Run("with nested changes trigger", func (t *testing.T) {
})
```

**Note**: After your PR has been merged, and the feature either reaches general availability, you should remove the `skipIfBeta()` flag.
**Note**: After your PR has been merged, and the feature either reaches general availability, you should remove the `skipUnlessBeta()` flag.

## Adding New Endpoints

Expand Down
14 changes: 10 additions & 4 deletions helper_test.go
Expand Up @@ -2146,7 +2146,7 @@ func randomSemver(t *testing.T) string {
}

// skips a test if the environment is for Terraform Cloud.
func skipIfCloud(t *testing.T) {
func skipUnlessEnterprise(t *testing.T) {
if !enterpriseEnabled() {
t.Skip("Skipping test related to Terraform Cloud. Set ENABLE_TFE=1 to run.")
}
Expand All @@ -2167,15 +2167,21 @@ func skipIfFreeOnly(t *testing.T) {
}
}

// skips a test if the test requires a beta feature
func skipIfBeta(t *testing.T) {
// skips a test if the underlying beta feature is not available.
// **Note: ENABLE_BETA is always disabled in CI, so ensure you:
//
// 1. Run tests locally and paste the test output in the resulting pull request
// 2. Remove the beta requirements of your feature from go-tfe once the feature is generally available.
//
// See CONTRIBUTING.md for details
func skipUnlessBeta(t *testing.T) {
if !betaFeaturesEnabled() {
t.Skip("Skipping test related to a Terraform Cloud beta feature. Set ENABLE_BETA=1 to run.")
}
}

// skips a test if the architecture is not linux_amd64
func skipIfNotLinuxAmd64(t *testing.T) {
func skipUnlessLinuxAMD64(t *testing.T) {
if !linuxAmd64() {
t.Skip("Skipping test if architecture is not linux_amd64")
}
Expand Down
6 changes: 3 additions & 3 deletions organization_integration_test.go
Expand Up @@ -182,7 +182,7 @@ func TestOrganizationsRead(t *testing.T) {
})

t.Run("reads default project", func(t *testing.T) {
skipIfBeta(t)
skipUnlessBeta(t)

org, err := client.Organizations.ReadWithOptions(ctx, orgTest.Name, OrganizationReadOptions{Include: []OrganizationIncludeOpt{OrganizationDefaultProject}})
require.NoError(t, err)
Expand Down Expand Up @@ -520,7 +520,7 @@ func TestOrganization_Unmarshal(t *testing.T) {

func TestOrganizationsReadRunTasksPermission(t *testing.T) {
skipIfFreeOnly(t)
skipIfBeta(t)
skipUnlessBeta(t)

client := testClient(t)
ctx := context.Background()
Expand All @@ -543,7 +543,7 @@ func TestOrganizationsReadRunTasksPermission(t *testing.T) {
func TestOrganizationsReadRunTasksEntitlement(t *testing.T) {
skipIfEnterprise(t)
skipIfFreeOnly(t)
skipIfBeta(t)
skipUnlessBeta(t)

client := testClient(t)
ctx := context.Background()
Expand Down

0 comments on commit d2e0e00

Please sign in to comment.