MCPcopy
hub / github.com/helm/helm / TestDeprecatedAPIFails

Function TestDeprecatedAPIFails

pkg/chart/v2/lint/rules/template_test.go:197–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195}
196
197func TestDeprecatedAPIFails(t *testing.T) {
198 modTime := time.Now()
199 mychart := chart.Chart{
200 Metadata: &chart.Metadata{
201 APIVersion: "v2",
202 Name: "failapi",
203 Version: "0.1.0",
204 Icon: "satisfy-the-linting-gods.gif",
205 },
206 Templates: []*common.File{
207 {
208 Name: "templates/baddeployment.yaml",
209 ModTime: modTime,
210 Data: []byte("apiVersion: apps/v1beta1\nkind: Deployment\nmetadata:\n name: baddep\nspec: {selector: {matchLabels: {foo: bar}}}"),
211 },
212 {
213 Name: "templates/goodsecret.yaml",
214 ModTime: modTime,
215 Data: []byte("apiVersion: v1\nkind: Secret\nmetadata:\n name: goodsecret"),
216 },
217 },
218 }
219 tmpdir := t.TempDir()
220
221 if err := chartutil.SaveDir(&mychart, tmpdir); err != nil {
222 t.Fatal(err)
223 }
224
225 linter := support.Linter{ChartDir: filepath.Join(tmpdir, mychart.Name())}
226 Templates(
227 &linter,
228 namespace,
229 values,
230 TemplateLinterSkipSchemaValidation(false))
231 if l := len(linter.Messages); l != 1 {
232 for i, msg := range linter.Messages {
233 t.Logf("Message %d: %s", i, msg)
234 }
235 t.Fatalf("Expected 1 lint error, got %d", l)
236 }
237
238 err := linter.Messages[0].Err.(deprecatedAPIError)
239 if err.Deprecated != "apps/v1beta1 Deployment" {
240 t.Errorf("Surprised to learn that %q is deprecated", err.Deprecated)
241 }
242}
243
244const manifest = `apiVersion: v1
245kind: ConfigMap

Callers

nothing calls this directly

Calls 6

NameMethod · 0.95
NowMethod · 0.80
FatalMethod · 0.80
FatalfMethod · 0.80
TemplatesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…