Commit 3e6ef66f
3e6ef66fdb1aMerged
Sviatoslav Dumchenko <[email protected]> ยท 3 years ago ยท 1 file ยท ~1 modified
Description
chore(tests): add more chart tests
Details
- Commit
- 3e6ef66fdb1a
- Parent
- 6ef0d0b18e74
pkg/release/chart_internal_test.gomodifiedView file
@@ -6,14 +6,20 @@
66
77
"github.com/stretchr/testify/suite"88
"helm.sh/helm/v3/pkg/action"9+
"helm.sh/helm/v3/pkg/chart"910
)1011
1112
type ChartInternalTestSuite struct {1213
suite.Suite1314
}1415
15-
func (s *ChartInternalTestSuite) contains(a []string, b string) bool {16-
s.T().Helper()16+
func TestChartInternalTestSuite(t *testing.T) {17+
t.Parallel()18+
suite.Run(t, new(ChartInternalTestSuite))19+
}20+
21+
func (ts *ChartInternalTestSuite) contains(a []string, b string) bool {22+
ts.T().Helper()1723
1824
for i := range a {1925
if a[i] == b {@@ -25,7 +31,7 @@
2531
}2632
2733
// TestChartTypeFields checks that all fields of helm upgrade action exist in config structure.28-
func (s *ChartInternalTestSuite) TestChartTypeFields() {34+
func (ts *ChartInternalTestSuite) TestChartTypeFields() {2935
skipFields := []string{3036
"Name",3137
}@@ -47,13 +53,45 @@
4753
if !f.IsExported() {4854
continue4955
}50-
if !s.contains(skipFields, f.Name) {51-
s.Require().Contains(fieldsR, f.Name)56+
if !ts.contains(skipFields, f.Name) {57+
ts.Require().Contains(fieldsR, f.Name)5258
}5359
}5460
}5561
56-
func TestChartInternalTestSuite(t *testing.T) {57-
t.Parallel()58-
suite.Run(t, new(ChartInternalTestSuite))62+
func (ts *ChartInternalTestSuite) TestChartCheckMissingDependency() {63+
rel := NewConfig()64+
err := rel.chartCheck(&chart.Chart{65+
Metadata: &chart.Metadata{66+
Dependencies: []*chart.Dependency{67+
{68+
Name: ts.T().Name(),69+
},70+
},71+
},72+
})73+
74+
ts.Require().ErrorContains(err, "found in Chart.yaml, but missing in charts/ directory")75+
}76+
77+
func (ts *ChartInternalTestSuite) TestChartCheckInvalidType() {78+
rel := NewConfig()79+
err := rel.chartCheck(&chart.Chart{80+
Metadata: &chart.Metadata{81+
Type: "library",82+
},83+
})84+
85+
ts.Require().NoError(err)86+
}87+
88+
func (ts *ChartInternalTestSuite) TestChartCheckDeprecated() {89+
rel := NewConfig()90+
err := rel.chartCheck(&chart.Chart{91+
Metadata: &chart.Metadata{92+
Deprecated: true,93+
},94+
})95+
96+
ts.Require().NoError(err)5997
}