Skip to content

Conversation

@Bishibop
Copy link
Contributor

@Bishibop Bishibop commented Oct 31, 2025

Summary

Adds 5 comprehensive integration tests covering the interaction between config file discovery (monorepo support) and autodiscovery mode.

Tests Added

  1. Subdirectory with parent config - Verifies subdirectories use parent's .replicated config instead of autodiscovery
  2. Subdirectory with empty parent config - Confirms autodiscovery triggers when parent config is empty
  3. Monorepo with multiple configs - Tests config merging across grandparent → parent → child directories
  4. Autodiscovery only when ALL arrays empty - Edge case: manifests configured but not charts/preflights
  5. No config anywhere - Tests autodiscovery from deep nested directories

Why These Tests Matter

These tests ensure the monorepo config merging logic and autodiscovery mode work correctly together. Previously, there were no tests verifying behavior when:

  • Running replicated lint from a subdirectory with a parent config
  • Multiple .replicated files need to be merged
  • Determining whether to use config mode vs autodiscovery mode

This gap meant we had no coverage for the FindAndParseConfig() monorepo support interacting with the autodiscovery logic.

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.
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.
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.
@Bishibop Bishibop merged commit a25fbcc into main Nov 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants