Skip to content

Commit a25fbcc

Browse files
authored
test: add config discovery vs autodiscovery test coverage (#639)
* test: add config discovery vs autodiscovery test coverage Add 5 comprehensive tests covering the interaction between config file discovery (walking up directory tree) and autodiscovery mode triggering. Tests added: - Subdirectory with parent config (uses config, not autodiscovery) - Subdirectory with empty parent config (triggers autodiscovery) - Monorepo with multiple configs (merges configs correctly) - Autodiscovery only when ALL arrays empty (edge case validation) - No config anywhere in tree (autodiscovery from any depth) These tests ensure the monorepo support and autodiscovery behavior work correctly together, which was previously untested. * refactor(test): migrate lint tests to use reusable fixtures Migrates 10 test functions in lint_test.go to use testdata fixtures instead of inline file creation, following the pattern established in image_extraction_test.go. Changes: - Add helper functions: getTestDataPath, copyFixtureToTemp - Create testdata/lint/ with 39 fixture files across 8 scenarios - Migrate tests: TestLint_VerboseFlag, TestLint_ChartValidationError, TestLint_AutodiscoveryWithMixedManifests, and 7 others - Reduce test file: 2,355 → 1,888 lines (20% reduction) - Reduce os.WriteFile calls: 74 → 42 (43% reduction) Fixtures created: - simple-chart/ - Basic chart for simple tests - multi-chart-project/ - Multiple charts scenario - chart-missing-helmchart/ - Validation error tests - orphaned-helmchart/ - Validation warning tests - mixed-manifests-autodiscovery/ - Mixed resource types - mixed-manifests-yaml-yml/ - Mixed file extensions (.yaml/.yml) - hidden-dirs-test/ - Hidden directory testing (.github) - configs/ - 6 reusable config templates Remaining inline tests use dynamic paths, test error scenarios, or are minimal configs where fixtures would add overhead. All tests pass. * chore(test): remove redundant fixture comments Per coding style guide to avoid commenting obvious operations. Removed 10 'Use fixture' comments where the fixture usage is self-explanatory from the getTestDataPath() function calls. Kept non-obvious comments like the .git runtime creation note which explains a technical constraint.
1 parent 1f00225 commit a25fbcc

File tree

39 files changed

+1067
-599
lines changed

39 files changed

+1067
-599
lines changed

cli/cmd/lint_test.go

Lines changed: 757 additions & 599 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
charts:
2+
- path: chart
3+
manifests:
4+
- manifests/*.yaml
5+
repl-lint:
6+
linters:
7+
helm:
8+
disabled: true
9+
preflight:
10+
disabled: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v2
2+
name: test-app
3+
version: 1.0.0
4+
description: Test chart without matching HelmChart manifest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty manifests directory - no HelmChart manifest
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
repl-lint:
2+
version: 1
3+
linters:
4+
helm: {}
5+
preflight: {}
6+
support-bundle: {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
repl-lint:
2+
linters:
3+
helm: {}
4+
preflight:
5+
disabled: true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
charts: []
2+
manifests: []
3+
preflights: []
4+
repl-lint:
5+
linters:
6+
helm: {}
7+
preflight:
8+
disabled: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repl-lint:
2+
tools:
3+
helm: "latest"
4+
preflight: "latest"
5+
support-bundle: "latest"
6+
linters:
7+
helm: {}
8+
preflight:
9+
disabled: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
repl-lint:
2+
tools:
3+
helm: "3.14.4"
4+
preflight: "0.123.9"
5+
support-bundle: "0.123.9"
6+
linters:
7+
helm: {}
8+
preflight:
9+
disabled: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
manifests:
2+
- manifests/*.yaml
3+
repl-lint:
4+
linters:
5+
helm: {}
6+
preflight: {}

0 commit comments

Comments
 (0)