Skip to content

Commit b35d8a7

Browse files
author
Ignacio Anaya
committed
chore: migrate tests to user keys
1 parent e8e2719 commit b35d8a7

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

.github/workflows/test.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ jobs:
3434
- name: Test
3535
run: go test -v ./...
3636
env:
37-
TF_VAR_checkly_api_key: ${{ secrets.CHECKLY_API_KEY }}
3837
CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }}
38+
TF_VAR_checkly_api_key: ${{ secrets.CHECKLY_API_KEY }}
39+
TF_VAR_checkly_account_id: ${{ secrets.CHECKLY_ACCOUNT_ID }}
40+
CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }}
3941
CHECKLY_API_URL: ${{ secrets.CHECKLY_API_URL }}
4042
TF_ACC: 1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Clone the repo, build the project and add it to your Terraform plugins directory
5252
git clone [email protected]:checkly/terraform-provider-checkly.git
5353
cd terraform-provider-checkly
5454
go test
55-
go build && CHECKLY_API_KEY=XXX go test -tags=integration
55+
go build && CHECKLY_API_KEY=xxx CHECKLY_ACCOUNT_ID=xxx go test -tags=integration
5656
```
5757

5858
<br>

checkly/integration_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ func getAPIKey(t *testing.T) string {
1414
if key == "" {
1515
t.Fatal("'CHECKLY_API_KEY' must be set for integration tests")
1616
}
17+
18+
return key
19+
}
20+
21+
func getAccountId(t *testing.T) string {
22+
key := os.Getenv("CHECKLY_ACCOUNT_ID")
23+
if key == "" {
24+
t.Fatal("'CHECKLY_ACCOUNT_ID' must be set for integration tests")
25+
}
1726
return key
1827
}
1928

@@ -22,7 +31,8 @@ func TestChecklyTerraformIntegration(t *testing.T) {
2231
terraformOptions := &terraform.Options{
2332
TerraformDir: "../",
2433
Vars: map[string]interface{}{
25-
"checkly_api_key": getAPIKey(t),
34+
"checkly_api_key": getAPIKey(t),
35+
"checkly_account_id": getAccountId(t),
2636
},
2737
}
2838
defer terraform.Destroy(t, terraformOptions)

checkly/test_util.go

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func testAccPreCheck(t *testing.T) {
2424
if os.Getenv("CHECKLY_API_KEY") == "" {
2525
t.Fatal("CHECKLY_API_KEY must be set for acceptance tests")
2626
}
27+
28+
if os.Getenv("CHECKLY_ACCOUNT_ID") == "" {
29+
t.Fatal("CHECKLY_ACCOUNT_ID must be set for acceptance tests")
30+
}
2731
}
2832

2933
func accTestCase(t *testing.T, steps []resource.TestStep) {

docs/guides/support-for-terraform-0.12.md

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Now expose the API key as an environment variable in your shell:
2828

2929
```bash
3030
export TF_VAR_checkly_api_key=<my_api_key>
31+
export TF_VAR_checkly_account_id=<my_account_id>
3132
```
3233

3334
### Usage
@@ -37,8 +38,12 @@ create a tf config file, for example, `example.tf`
3738
variable "checkly_api_key" {
3839
}
3940
41+
variable "checkly_account_id" {
42+
}
43+
4044
provider "checkly" {
4145
api_key = var.checkly_api_key
46+
account_id = var.checkly_account_id
4247
}
4348
4449
resource "checkly_group" "group1" {

versions.tf

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ terraform {
1414
variable "checkly_api_key" {
1515
}
1616

17+
variable "checkly_account_id" {
18+
}
19+
1720
provider "checkly" {
1821
api_key = var.checkly_api_key
22+
account_id = var.checkly_account_id
1923
}

0 commit comments

Comments
 (0)