feat: add_testing #45
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
|
||||
- main
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# every sunday at 00:00
|
||||
# - cron: '0 0 * * 0'
|
||||
# every day at 00:00
|
||||
- cron: '0 0 * * *'
|
||||
push:
|
||||
branches:
|
||||
- '!main'
|
||||
|
|
@ -100,7 +105,9 @@ jobs:
|
|||
--version=${VERSION}
|
||||
|
||||
|
||||
|
||||
main:
|
||||
if: ${{ github.event_name != 'schedule' }}
|
||||
name: CI
|
||||
runs-on: ubuntu-latest
|
||||
needs: config
|
||||
|
|
@ -146,6 +153,7 @@ jobs:
|
|||
path: "stackit/${{ env.CODE_COVERAGE_FILE_NAME }}"
|
||||
|
||||
config:
|
||||
if: ${{ github.event_name != 'schedule' }}
|
||||
name: Check GoReleaser config
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
|
|||
3
Makefile
3
Makefile
|
|
@ -34,8 +34,7 @@ fmt:
|
|||
@terraform fmt -diff -recursive
|
||||
|
||||
# TEST
|
||||
.PHONY: test-full test coverage
|
||||
test-full: test coverage
|
||||
.PHONY: test coverage
|
||||
test:
|
||||
@echo "Running tests for the terraform provider"
|
||||
@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{
|
||||
"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() {
|
||||
|
|
@ -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) {
|
||||
// Check if acceptance tests should be run
|
||||
if v := os.Getenv(resource.EnvTfAcc); v == "" {
|
||||
|
|
@ -146,13 +143,7 @@ func TestAccEnvVarTokenValid(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
token, err := getServiceAccountToken()
|
||||
if err != nil {
|
||||
t.Fatalf("Can't get token: %v", err)
|
||||
}
|
||||
|
||||
t.Setenv("STACKIT_CREDENTIALS_PATH", "")
|
||||
t.Setenv("STACKIT_SERVICE_ACCOUNT_TOKEN", token)
|
||||
tempHomeFolder := createTemporaryHome(false, t)
|
||||
defer cleanupTemporaryHome(tempHomeFolder, t)
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue