Skip to content

Commit

Permalink
Add Azure DevOps Project datasource test config
Browse files Browse the repository at this point in the history
  • Loading branch information
csquire committed Dec 12, 2024
1 parent 614a2b4 commit 66f6665
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export DBT_CLOUD_ACCOUNT_ID=1234
export DBT_CLOUD_USER_ID=4321
export DBT_CLOUD_USER_EMAIL=[email protected]
export DBT_CLOUD_TOKEN=<api_token>
export DBT_CLOUD_PERSONAL_ACCESS_TOKEN=<api_token>
export DBT_CLOUD_HOST_URL=https://<api_host>/api
export DBT_CLOUD_GROUP_IDS=1,2,3
export ACC_TEST_DBT_CLOUD_USER_ID=4321
export ACC_TEST_DBT_CLOUD_USER_EMAIL=[email protected]
export ACC_TEST_DBT_CLOUD_GROUP_IDS=1,2,3
export ACC_TEST_GITHUB_REPO_URL=[email protected]:<github-org>/<dbt-project>.git
export ACC_TEST_GITHUB_APP_INSTALLATION_ID=5678
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<email_address>
ACC_TEST_DBT_CLOUD_USER_ID=4321
ACC_TEST_DBT_CLOUD_USER_EMAIL=<email_address>
DBT_CLOUD_TOKEN=<api_token>
DBT_CLOUD_HOST_URL=https://<host>/api
DBT_CLOUD_GROUP_IDS=1,2,3
ACC_TEST_DBT_CLOUD_GROUP_IDS=1,2,3
[email protected]:<github-org>/<dbt-project>.git
ACC_TEST_GITHUB_APP_INSTALLATION_ID=1234
```
Expand Down
36 changes: 25 additions & 11 deletions pkg/framework/acctest_config/acctest_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package azure_dev_ops_project_test

import (
"github.com/dbt-labs/terraform-provider-dbtcloud/pkg/framework/acctest_config"
"os"
"testing"

Expand All @@ -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) },
Expand Down

0 comments on commit 66f6665

Please sign in to comment.