chore: revise tests
This commit is contained in:
parent
55eeed71f0
commit
3505fb56f0
3 changed files with 15 additions and 17 deletions
8
.github/workflows/ci.yaml
vendored
8
.github/workflows/ci.yaml
vendored
|
|
@ -6,6 +6,11 @@ on:
|
||||||
- alpha
|
- alpha
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
# every sunday at 00:00
|
||||||
|
# - cron: '0 0 * * 0'
|
||||||
|
# every day at 00:00
|
||||||
|
- cron: '0 0 * * *'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '!main'
|
- '!main'
|
||||||
|
|
@ -100,7 +105,9 @@ jobs:
|
||||||
--version=${VERSION}
|
--version=${VERSION}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main:
|
main:
|
||||||
|
if: ${{ github.event_name != 'schedule' }}
|
||||||
name: CI
|
name: CI
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: config
|
needs: config
|
||||||
|
|
@ -146,6 +153,7 @@ jobs:
|
||||||
path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
|
path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
|
||||||
|
|
||||||
config:
|
config:
|
||||||
|
if: ${{ github.event_name != 'schedule' }}
|
||||||
name: Check GoReleaser config
|
name: Check GoReleaser config
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
||||||
3
Makefile
3
Makefile
|
|
@ -34,8 +34,7 @@ fmt:
|
||||||
@terraform fmt -diff -recursive
|
@terraform fmt -diff -recursive
|
||||||
|
|
||||||
# TEST
|
# TEST
|
||||||
.PHONY: test-full test coverage
|
.PHONY: test coverage
|
||||||
test-full: test coverage
|
|
||||||
test:
|
test:
|
||||||
@echo "Running tests for the terraform provider"
|
@echo "Running tests for the terraform provider"
|
||||||
@cd $(ROOT_DIR)/stackit && go test ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR)
|
@cd $(ROOT_DIR)/stackit && go test ./... -count=1 -coverprofile=../coverage.out && cd $(ROOT_DIR)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,12 @@ var providerValidAttributes string
|
||||||
|
|
||||||
var testConfigProviderCredentials = config.Variables{
|
var testConfigProviderCredentials = config.Variables{
|
||||||
"project_id": config.StringVariable(testutil.ProjectId),
|
"project_id": config.StringVariable(testutil.ProjectId),
|
||||||
"name": config.StringVariable(fmt.Sprintf("tf-acc-prov%s", acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum))),
|
"name": config.StringVariable(
|
||||||
|
fmt.Sprintf(
|
||||||
|
"tf-acc-prov%s",
|
||||||
|
acctest.RandStringFromCharSet(3, acctest.CharSetAlphaNum),
|
||||||
|
),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
|
|
@ -129,14 +134,6 @@ func cleanupTemporaryHome(tempHomePath string, t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServiceAccountToken() (string, error) {
|
|
||||||
token, set := os.LookupEnv("TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN")
|
|
||||||
if !set || token == "" {
|
|
||||||
return "", fmt.Errorf("Token not set, please set TF_ACC_TEST_PROJECT_SERVICE_ACCOUNT_TOKEN to a valid token to perform tests")
|
|
||||||
}
|
|
||||||
return token, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAccEnvVarTokenValid(t *testing.T) {
|
func TestAccEnvVarTokenValid(t *testing.T) {
|
||||||
// Check if acceptance tests should be run
|
// Check if acceptance tests should be run
|
||||||
if v := os.Getenv(resource.EnvTfAcc); v == "" {
|
if v := os.Getenv(resource.EnvTfAcc); v == "" {
|
||||||
|
|
@ -146,13 +143,7 @@ func TestAccEnvVarTokenValid(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := getServiceAccountToken()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Can't get token: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
|
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
|
||||||
t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token)
|
|
||||||
tempHomeFolder := createTemporaryHome(false, t)
|
tempHomeFolder := createTemporaryHome(false, t)
|
||||||
defer cleanupTemporaryHome(tempHomeFolder, t)
|
defer cleanupTemporaryHome(tempHomeFolder, t)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue