test(provisioner/terraform): clean up testdata structure (#17074)

This commit is contained in:
Mathias Fredriksson
2025-03-24 16:34:56 +02:00
committed by GitHub
parent 4e38e6de04
commit d570ce7246
117 changed files with 26 additions and 24 deletions
+7 -7
View File
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
+12 -17
View File
@@ -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"
@@ -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
@@ -21,6 +21,7 @@
"motd_file": null,
"order": null,
"os": "windows",
"resources_monitoring": [],
"shutdown_script": null,
"startup_script": null,
"startup_script_behavior": "non-blocking",
@@ -29,6 +30,7 @@
"sensitive_values": {
"display_apps": [],
"metadata": [],
"resources_monitoring": [],
"token": true
}
},
@@ -69,6 +71,7 @@
"motd_file": null,
"order": null,
"os": "windows",
"resources_monitoring": [],
"shutdown_script": null,
"startup_script": null,
"startup_script_behavior": "non-blocking",
@@ -79,12 +82,14 @@
"id": true,
"init_script": true,
"metadata": [],
"resources_monitoring": [],
"token": true
},
"before_sensitive": false,
"after_sensitive": {
"display_apps": [],
"metadata": [],
"resources_monitoring": [],
"token": true
}
}
@@ -77,6 +77,7 @@
"motd_file": null,
"order": null,
"os": "windows",
"resources_monitoring": [],
"shutdown_script": null,
"startup_script": null,
"startup_script_behavior": "non-blocking",
@@ -88,6 +89,7 @@
{}
],
"metadata": [],
"resources_monitoring": [],
"token": true
}
},

Some files were not shown because too many files have changed in this diff Show More