1
0
mirror of https://github.com/helm/chart-testing.git synced 2026-02-05 09:45:14 +01:00

Fix excluded chart when chart-dirs is multi-level (#312)

Signed-off-by: nekottyo <nekottyo@gmail.com>
This commit is contained in:
Kotaro Shimizu
2022-03-23 18:13:31 +09:00
committed by GitHub
parent 9b80b21aac
commit a66bd3363c
6 changed files with 26 additions and 0 deletions

View File

@@ -724,7 +724,14 @@ func (t *Testing) ComputeChangedChartDirectories() ([]string, error) {
dir := filepath.Dir(file)
// Make sure directory is really a chart directory
chartDir, err := t.chartUtils.LookupChartDir(cfg.ChartDirs, dir)
chartDirElement := strings.Split(chartDir, "/")
if err == nil {
if len(chartDirElement) > 1 {
chartDirName := chartDirElement[len(chartDirElement)-1]
if util.StringSliceContains(cfg.ExcludedCharts, chartDirName) {
continue
}
}
// Only add it if not already in the list
if !util.StringSliceContains(changedChartDirs, chartDir) {
changedChartDirs = append(changedChartDirs, chartDir)

View File

@@ -45,7 +45,11 @@ func (g fakeGit) ListChangedFilesInDirs(commit string, dirs ...string) ([]string
"test_charts/foo/Chart.yaml",
"test_charts/bar/Chart.yaml",
"test_charts/bar/bar_sub/templates/bar_sub.yaml",
"test_charts/excluded/Chart.yaml",
"test_chart_at_root/templates/foo.yaml",
"test_chart_at_multi_level/foo/bar/Chart.yaml",
"test_chart_at_multi_level/foo/baz/Chart.yaml",
"test_chart_at_multi_level/foo/excluded/Chart.yaml",
"some_non_chart_dir/some_non_chart_file",
"some_non_chart_file",
}, nil
@@ -152,6 +156,21 @@ func TestComputeChangedChartDirectories(t *testing.T) {
assert.Nil(t, err)
}
func TestComputeChangedChartDirectoriesWithMultiLevelChart(t *testing.T) {
cfg := config.Configuration{
ExcludedCharts: []string{"excluded"},
ChartDirs: []string{"test_chart_at_multi_level/foo"},
}
ct := newTestingMock(cfg)
actual, err := ct.ComputeChangedChartDirectories()
expected := []string{"test_chart_at_multi_level/foo/bar", "test_chart_at_multi_level/foo/baz"}
for _, chart := range actual {
assert.Contains(t, expected, chart)
}
assert.Len(t, actual, 2)
assert.Nil(t, err)
}
func TestReadAllChartDirectories(t *testing.T) {
actual, err := ct.ReadAllChartDirectories()
expected := []string{