github.com/cloudposse/helm@v2.2.3+incompatible/pkg/chartutil/chartfile_test.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package chartutil 18 19 import ( 20 "testing" 21 22 "k8s.io/helm/pkg/proto/hapi/chart" 23 ) 24 25 const testfile = "testdata/chartfiletest.yaml" 26 27 func TestLoadChartfile(t *testing.T) { 28 f, err := LoadChartfile(testfile) 29 if err != nil { 30 t.Errorf("Failed to open %s: %s", testfile, err) 31 return 32 } 33 verifyChartfile(t, f, "frobnitz") 34 } 35 36 func verifyChartfile(t *testing.T, f *chart.Metadata, name string) { 37 38 if f == nil { 39 t.Fatal("Failed verifyChartfile because f is nil") 40 } 41 42 // Api instead of API because it was generated via protobuf. 43 if f.ApiVersion != ApiVersionV1 { 44 t.Errorf("Expected API Version %q, got %q", ApiVersionV1, f.ApiVersion) 45 } 46 47 if f.Name != name { 48 t.Errorf("Expected %s, got %s", name, f.Name) 49 } 50 51 if f.Description != "This is a frobnitz." { 52 t.Errorf("Unexpected description %q", f.Description) 53 } 54 55 if f.Version != "1.2.3" { 56 t.Errorf("Unexpected version %q", f.Version) 57 } 58 59 if len(f.Maintainers) != 2 { 60 t.Errorf("Expected 2 maintainers, got %d", len(f.Maintainers)) 61 } 62 63 if f.Maintainers[0].Name != "The Helm Team" { 64 t.Errorf("Unexpected maintainer name.") 65 } 66 67 if f.Maintainers[1].Email != "nobody@example.com" { 68 t.Errorf("Unexpected maintainer email.") 69 } 70 71 if len(f.Sources) != 1 { 72 t.Fatalf("Unexpected number of sources") 73 } 74 75 if f.Sources[0] != "https://example.com/foo/bar" { 76 t.Errorf("Expected https://example.com/foo/bar, got %s", f.Sources) 77 } 78 79 if f.Home != "http://example.com" { 80 t.Error("Unexpected home.") 81 } 82 83 if f.Icon != "https://example.com/64x64.png" { 84 t.Errorf("Unexpected icon: %q", f.Icon) 85 } 86 87 if len(f.Keywords) != 3 { 88 t.Error("Unexpected keywords") 89 } 90 91 kk := []string{"frobnitz", "sprocket", "dodad"} 92 for i, k := range f.Keywords { 93 if kk[i] != k { 94 t.Errorf("Expected %q, got %q", kk[i], k) 95 } 96 } 97 }