diff --git a/.env.example b/.env.example index 28a31a6..dc07b01 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,9 @@ export DBT_CLOUD_ACCOUNT_ID=1234 -export DBT_CLOUD_USER_ID=4321 -export DBT_CLOUD_USER_EMAIL=user@example.com export DBT_CLOUD_TOKEN= +export DBT_CLOUD_PERSONAL_ACCESS_TOKEN= export DBT_CLOUD_HOST_URL=https:///api -export DBT_CLOUD_GROUP_IDS=1,2,3 +export ACC_TEST_DBT_CLOUD_USER_ID=4321 +export ACC_TEST_DBT_CLOUD_USER_EMAIL=user@example.com +export ACC_TEST_DBT_CLOUD_GROUP_IDS=1,2,3 export ACC_TEST_GITHUB_REPO_URL=git@github.com:/.git export ACC_TEST_GITHUB_APP_INSTALLATION_ID=5678 \ No newline at end of file diff --git a/README.md b/README.md index dcd6e64..3f850a5 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,11 @@ for a dbt Cloud account the tests can interact with. All dbt Cloud resources ref (e.g. user id, email address, and group ids) must exist in the dbt Cloud account. ``` DBT_CLOUD_ACCOUNT_ID=1234 -DBT_CLOUD_USER_ID=4321 -DBT_CLOUD_USER_EMAIL= +ACC_TEST_DBT_CLOUD_USER_ID=4321 +ACC_TEST_DBT_CLOUD_USER_EMAIL= DBT_CLOUD_TOKEN= DBT_CLOUD_HOST_URL=https:///api -DBT_CLOUD_GROUP_IDS=1,2,3 +ACC_TEST_DBT_CLOUD_GROUP_IDS=1,2,3 ACC_TEST_GITHUB_REPO_URL=git@github.com:/.git ACC_TEST_GITHUB_APP_INSTALLATION_ID=1234 ``` diff --git a/pkg/framework/acctest_config/acctest_config.go b/pkg/framework/acctest_config/acctest_config.go index 4bc6fd7..02b92c2 100644 --- a/pkg/framework/acctest_config/acctest_config.go +++ b/pkg/framework/acctest_config/acctest_config.go @@ -10,21 +10,32 @@ var AcceptanceTestConfig = buildAcctestConfig() func buildAcctestConfig() AcctestConfig { return AcctestConfig{ - DbtCloudAccountId: determineIntValue("DBT_CLOUD_ACCOUNT_ID", 1, 1), - DbtCloudServiceToken: os.Getenv("DBT_CLOUD_TOKEN"), - DbtCloudHostUrl: determineStringValue("DBT_CLOUD_HOST_URL", "", ""), - DbtCloudVersion: "versionless", - DbtCloudUserId: determineIntValue("DBT_CLOUD_USER_ID", 1, 54461), + DbtCloudAccountId: determineIntValue("DBT_CLOUD_ACCOUNT_ID", 1, 1), + DbtCloudServiceToken: os.Getenv("DBT_CLOUD_TOKEN"), + DbtCloudPersonalAccessToken: os.Getenv("DBT_CLOUD_PERSONAL_ACCESS_TOKEN"), + DbtCloudHostUrl: determineStringValue("DBT_CLOUD_HOST_URL", "", ""), + DbtCloudVersion: "versionless", + + DbtCloudUserId: determineIntValue( + "ACC_TEST_DBT_CLOUD_USER_ID", + 1, + 54461, + ), DbtCloudUserEmail: determineStringValue( - "DBT_CLOUD_USER_EMAIL", + "ACC_TEST_DBT_CLOUD_USER_EMAIL", "d"+"ev@"+"db"+"tla"+"bs.c"+"om", "beno"+"it"+".per"+"igaud"+"@"+"fisht"+"ownanalytics"+"."+"com", ), DbtCloudGroupIds: determineStringValue( - "DBT_CLOUD_GROUP_IDS", + "ACC_TEST_DBT_CLOUD_GROUP_IDS", "1,2,3", "531585,531584,531583", ), + AzureDevOpsProjectName: determineStringValue( + "ACC_TEST_AZURE_DEVOPS_PROJECT_NAME", + "dbt-cloud-ado-project", + "dbt-cloud-ado-project", + ), GitHubRepoUrl: determineStringValue( "ACC_TEST_GITHUB_REPO_URL", "git://github.com/dbt-labs/jaffle_shop.git", @@ -39,13 +50,16 @@ func buildAcctestConfig() AcctestConfig { } type AcctestConfig struct { - DbtCloudAccountId int - DbtCloudServiceToken string - DbtCloudHostUrl string - DbtCloudVersion string + DbtCloudAccountId int + DbtCloudServiceToken string + DbtCloudPersonalAccessToken string + DbtCloudHostUrl string + DbtCloudVersion string + DbtCloudUserId int DbtCloudUserEmail string DbtCloudGroupIds string + AzureDevOpsProjectName string GitHubRepoUrl string GitHubAppInstallationId int } diff --git a/pkg/framework/objects/azure_dev_ops_project/data_source_acceptance_test.go b/pkg/framework/objects/azure_dev_ops_project/data_source_acceptance_test.go index 6e9b931..08deeef 100644 --- a/pkg/framework/objects/azure_dev_ops_project/data_source_acceptance_test.go +++ b/pkg/framework/objects/azure_dev_ops_project/data_source_acceptance_test.go @@ -1,6 +1,7 @@ package azure_dev_ops_project_test import ( + "github.com/dbt-labs/terraform-provider-dbtcloud/pkg/framework/acctest_config" "os" "testing" @@ -10,19 +11,18 @@ import ( ) func TestAccDbtCloudAzureDevOpsProject(t *testing.T) { - //TODO: Remove both env var checks when this gets configurted in CI and the variables are parameterized + //TODO: Remove both env var checks when this gets configured in CI and the variables are parameterized if os.Getenv("CI") != "" { t.Skip("Skipping Azure DevOps Project datasource test in CI " + "until Azure integration and a personal access token are available") } - if os.Getenv("DBT_CLOUD_PERSONAL_ACCESS_TOKEN") == "" { + personalAccessToken := acctest_config.AcceptanceTestConfig.DbtCloudPersonalAccessToken + if personalAccessToken == "" { t.Skip("Skipping Azure DevOps Project datasource because no personal access token is available") } - //TODO: Parameterize these values when a standard method is available for parameterization - adoProjectName := "dbt-cloud-ado-project" - personalAccessToken := os.Getenv("DBT_CLOUD_PERSONAL_ACCESS_TOKEN") + adoProjectName := acctest_config.AcceptanceTestConfig.AzureDevOpsProjectName resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest_helper.TestAccPreCheck(t) },