Skip to content

Commit 739b926

Browse files
committed
add failing tests for valid units
1 parent adad0cb commit 739b926

File tree

6 files changed

+144
-0
lines changed

6 files changed

+144
-0
lines changed

.zed/tasks.json

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Project tasks configuration. See https://zed.dev/docs/tasks for documentation.
2+
//
3+
// Example:
4+
[
5+
{
6+
"label": "Lint",
7+
"command": "make run-lint",
8+
"reveal": "no_focus",
9+
"hide": "on_success"
10+
},
11+
{
12+
"label": "Strict Lint",
13+
"command": "make run-strict-lint",
14+
"reveal": "no_focus",
15+
"hide": "on_success"
16+
},
17+
{
18+
"label": "Test Package",
19+
"command": "go test",
20+
"args": ["./$ZED_RELATIVE_DIR"],
21+
"reveal": "no_focus",
22+
"hide": "on_success"
23+
},
24+
{
25+
"label": "Lint Package",
26+
"command": "golangci-lint run -v --timeout=10m",
27+
"args": ["./$ZED_RELATIVE_DIR"],
28+
"reveal": "no_focus",
29+
"hide": "on_success"
30+
},
31+
{
32+
"label": "This Test",
33+
"command": "go",
34+
"args": ["test", "./$ZED_RELATIVE_DIR", "-v", "-run", "$ZED_SYMBOL"],
35+
"reveal": "no_focus",
36+
"hide": "on_success"
37+
},
38+
{
39+
"label": "Example task",
40+
"command": "for i in {1..5}; do echo \"Hello $i/5\"; sleep 1; done",
41+
//"args": [],
42+
// Env overrides for the command, will be appended to the terminal's environment from the settings.
43+
"env": { "foo": "bar" },
44+
// Current working directory to spawn the command into, defaults to current project root.
45+
//"cwd": "/path/to/working/directory",
46+
// Whether to use a new terminal tab or reuse the existing one to spawn the process, defaults to `false`.
47+
"use_new_terminal": false,
48+
// Whether to allow multiple instances of the same task to be run, or rather wait for the existing ones to finish, defaults to `false`.
49+
"allow_concurrent_runs": false,
50+
// What to do with the terminal pane and tab, after the command was started:
51+
// * `always` — always show the task's pane, and focus the corresponding tab in it (default)
52+
// * `no_focus` — always show the task's pane, add the task's tab in it, but don't focus it
53+
// * `never` — do not alter focus, but still add/reuse the task's tab in its pane
54+
"reveal": "always",
55+
// Where to place the task's terminal item after starting the task:
56+
// * `dock` — in the terminal dock, "regular" terminal items' place (default)
57+
// * `center` — in the central pane group, "main" editor area
58+
"reveal_target": "dock",
59+
// What to do with the terminal pane and tab, after the command had finished:
60+
// * `never` — Do nothing when the command finishes (default)
61+
// * `always` — always hide the terminal tab, hide the pane also if it was the last tab in it
62+
// * `on_success` — hide the terminal tab on task success only, otherwise behaves similar to `always`
63+
"hide": "never",
64+
// Which shell to use when running a task inside the terminal.
65+
// May take 3 values:
66+
// 1. (default) Use the system's default terminal configuration in /etc/passwd
67+
// "shell": "system"
68+
// 2. A program:
69+
// "shell": {
70+
// "program": "sh"
71+
// }
72+
// 3. A program with arguments:
73+
// "shell": {
74+
// "with_arguments": {
75+
// "program": "/bin/bash",
76+
// "args": ["--login"]
77+
// }
78+
// }
79+
"shell": "system",
80+
// Whether to show the task line in the output of the spawned task, defaults to `true`.
81+
"show_summary": true,
82+
// Whether to show the command line in the output of the spawned task, defaults to `true`.
83+
"show_command": true
84+
// Represents the tags for inline runnable indicators, or spawning multiple tasks at once.
85+
// "tags": []
86+
}
87+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
locals {
2+
variable_source = "github.com/foo/bar"
3+
}
4+
5+
module "module" {
6+
source = local.variable_source
7+
version = "0.0.0"
8+
}

test/fixtures/hclvalidate/valid/var-in-source/terragrunt.hcl

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
locals {
2+
variable_version = "0.0.0"
3+
}
4+
5+
module "module" {
6+
source = "github.com/foo/bar"
7+
version = local.variable_version
8+
}

test/fixtures/hclvalidate/valid/var-in-version/terragrunt.hcl

Whitespace-only changes.

test/integration_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,47 @@ func TestTerragruntExcludesFile(t *testing.T) {
614614
}
615615
}
616616

617+
func TestHclvalidateValidConfig(t *testing.T) {
618+
t.Parallel()
619+
620+
t.Run("using --all", func(t *testing.T) {
621+
t.Parallel()
622+
helpers.CleanupTerraformFolder(t, testFixtureHclvalidate)
623+
tmpEnvPath := helpers.CopyEnvironment(t, testFixtureHclvalidate)
624+
rootPath := util.JoinPath(tmpEnvPath, testFixtureHclvalidate)
625+
626+
_, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt hcl validate --all --strict --inputs --working-dir "+path.Join(rootPath, "valid"))
627+
require.NoError(t, err)
628+
})
629+
630+
t.Run("each validate individually", func(t *testing.T) {
631+
t.Parallel()
632+
633+
helpers.CleanupTerraformFolder(t, testFixtureHclvalidate)
634+
tmpEnvPath := helpers.CopyEnvironment(t, testFixtureHclvalidate)
635+
rootPath := util.JoinPath(tmpEnvPath, testFixtureHclvalidate, "valid")
636+
637+
// Test each subdirectory individually
638+
entries, err := os.ReadDir(rootPath)
639+
require.NoError(t, err)
640+
641+
for _, entry := range entries {
642+
if !entry.IsDir() {
643+
continue
644+
}
645+
646+
subPath := filepath.Join(rootPath, entry.Name())
647+
648+
t.Run(entry.Name(), func(t *testing.T) {
649+
t.Parallel()
650+
651+
_, _, err := helpers.RunTerragruntCommandWithOutput(t, "terragrunt hcl validate --strict --inputs --working-dir "+subPath)
652+
require.NoError(t, err)
653+
})
654+
}
655+
})
656+
}
657+
617658
func TestHclvalidateDiagnostic(t *testing.T) {
618659
t.Parallel()
619660

0 commit comments

Comments
 (0)