(t *testing.T)
| 195 | } |
| 196 | |
| 197 | func 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 | |
| 244 | const manifest = `apiVersion: v1 |
| 245 | kind: ConfigMap |
nothing calls this directly
no test coverage detected
searching dependent graphs…