Skip to content

Commit

Permalink
test: updated tests for function resource
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-s committed Jul 31, 2024
1 parent fa0837e commit 0fe81e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 11 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Qernal Terraform

Running the tests;
Before running the tests, you'll need to build and install the provider
which can be done with;

```bash
go mod download
make local-build
make local-install
```

Running the tests;

```bash
go test ./tests
```

However, if you need to supply extra environment vars such as the token or a different
build environment then this can be done like so;

```
```bash
QERNAL_CHAOS_ENDPOINT=https://chaos.qernal.com QERNAL_HYDRA_ENDPOINT=https://hydra.qernal.com QERNAL_TOKEN=$(cat ./qernal-token) go test ./tests
```
5 changes: 3 additions & 2 deletions tests/modules/single_function/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "qernal_function" "function" {
cpu = 128
memory = 128
}
compliance = []
compliance = ["ipv6"] // TODO: allow this to be blank

deployment {
location = {
Expand All @@ -41,6 +41,7 @@ resource "qernal_function" "function" {

route {
path = "/*"
methods = "GET, HEAD"
methods = ["GET", "HEAD"]
weight = 100
}
}
5 changes: 2 additions & 3 deletions tests/qernal_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestEnvironmentSecret(t *testing.T) {
},
})

defer deleteProj(projectId)
defer deleteOrg(orgId)
defer deleteProj(projectId)
defer terraform.Destroy(t, terraformOptions)

terraform.InitAndApply(t, terraformOptions)
Expand Down Expand Up @@ -106,8 +106,8 @@ func TestRegistrySecret(t *testing.T) {
},
})

defer deleteProj(projectId)
defer deleteOrg(orgId)
defer deleteProj(projectId)
defer terraform.Destroy(t, terraformOptions)

terraform.InitAndApply(t, terraformOptions)
Expand All @@ -118,5 +118,4 @@ func TestRegistrySecret(t *testing.T) {

outputSecretValue := terraform.Output(t, terraformOptions, "secret_value")
assert.Equal(t, registryUrl, outputSecretValue)

}

0 comments on commit 0fe81e0

Please sign in to comment.