Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions provisioner/terraform/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func TestConvertResources(t *testing.T) {
expected := expected
t.Run(folderName, func(t *testing.T) {
t.Parallel()
dir := filepath.Join(filepath.Dir(filename), "testdata", folderName)
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", folderName)
t.Run("Plan", func(t *testing.T) {
t.Parallel()
ctx, logger := ctxAndLogger(t)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ func TestAppSlugValidation(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)

// Load the multiple-apps state file and edit it.
dir := filepath.Join(filepath.Dir(filename), "testdata", "multiple-apps")
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", "multiple-apps")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "multiple-apps.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand Down Expand Up @@ -1070,7 +1070,7 @@ func TestAppSlugDuplicate(t *testing.T) {
// nolint:dogsled
_, filename, _, _ := runtime.Caller(0)

dir := filepath.Join(filepath.Dir(filename), "testdata", "multiple-apps")
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", "multiple-apps")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "multiple-apps.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand Down Expand Up @@ -1098,7 +1098,7 @@ func TestAgentNameInvalid(t *testing.T) {
// nolint:dogsled
_, filename, _, _ := runtime.Caller(0)

dir := filepath.Join(filepath.Dir(filename), "testdata", "multiple-agents")
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", "multiple-agents")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "multiple-agents.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand Down Expand Up @@ -1147,7 +1147,7 @@ func TestAgentNameDuplicate(t *testing.T) {
// nolint:dogsled
_, filename, _, _ := runtime.Caller(0)

dir := filepath.Join(filepath.Dir(filename), "testdata", "multiple-agents")
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", "multiple-agents")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "multiple-agents.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand Down Expand Up @@ -1178,7 +1178,7 @@ func TestMetadataResourceDuplicate(t *testing.T) {
ctx, logger := ctxAndLogger(t)

// Load the multiple-apps state file and edit it.
dir := filepath.Join("testdata", "resource-metadata-duplicate")
dir := filepath.Join("testdata", "resources", "resource-metadata-duplicate")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "resource-metadata-duplicate.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand All @@ -1201,7 +1201,7 @@ func TestParameterValidation(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)

// Load the rich-parameters state file and edit it.
dir := filepath.Join(filepath.Dir(filename), "testdata", "rich-parameters")
dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", "rich-parameters")
tfPlanRaw, err := os.ReadFile(filepath.Join(dir, "rich-parameters.tfplan.json"))
require.NoError(t, err)
var tfPlan tfjson.Plan
Expand Down
29 changes: 12 additions & 17 deletions provisioner/terraform/testdata/generate.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
cd "$(dirname "${BASH_SOURCE[0]}")/resources"

generate() {
local name="$1"
Expand Down Expand Up @@ -70,22 +70,17 @@ run() {
cd "$d"
name=$(basename "$(pwd)")

# This needs care to update correctly.
if [[ $name == "kubernetes-metadata" ]]; then
echo "== Skipping: $name"
return 0
fi

# This directory is used for a different purpose (quick workaround).
if [[ $name == "cleanup-stale-plugins" ]]; then
echo "== Skipping: $name"
return 0
fi

if [[ $name == "timings-aggregation" ]]; then
echo "== Skipping: $name"
return 0
fi
toskip=(
# This needs care to update correctly.
"kubernetes-metadata"
)
for skip in "${toskip[@]}"; do
if [[ $name == "$skip" ]]; then
echo "== Skipping: $name"
touch "$name.tfplan.json" "$name.tfplan.dot" "$name.tfstate.json" "$name.tfstate.dot"
return 0
fi
done

echo "== Generating test data for: $name"
if ! out="$(generate "$name" 2>&1)"; then
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading