github.com/danielqsj/helm@v2.0.0-alpha.4.0.20160908204436-976e0ba5199b+incompatible/pkg/chartutil/create_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 "io/ioutil" 21 "os" 22 "path/filepath" 23 "testing" 24 25 "k8s.io/helm/pkg/proto/hapi/chart" 26 ) 27 28 func TestCreate(t *testing.T) { 29 tdir, err := ioutil.TempDir("", "helm-") 30 if err != nil { 31 t.Fatal(err) 32 } 33 defer os.RemoveAll(tdir) 34 35 cf := &chart.Metadata{Name: "foo"} 36 37 c, err := Create(cf, tdir) 38 if err != nil { 39 t.Fatal(err) 40 } 41 42 dir := filepath.Join(tdir, "foo") 43 44 mychart, err := LoadDir(c) 45 if err != nil { 46 t.Fatalf("Failed to load newly created chart %q: %s", c, err) 47 } 48 49 if mychart.Metadata.Name != "foo" { 50 t.Errorf("Expected name to be 'foo', got %q", mychart.Metadata.Name) 51 } 52 53 for _, d := range []string{TemplatesDir, ChartsDir} { 54 if fi, err := os.Stat(filepath.Join(dir, d)); err != nil { 55 t.Errorf("Expected %s dir: %s", d, err) 56 } else if !fi.IsDir() { 57 t.Errorf("Expected %s to be a directory.", d) 58 } 59 } 60 61 for _, f := range []string{ChartfileName, ValuesfileName, IgnorefileName} { 62 if fi, err := os.Stat(filepath.Join(dir, f)); err != nil { 63 t.Errorf("Expected %s file: %s", f, err) 64 } else if fi.IsDir() { 65 t.Errorf("Expected %s to be a fle.", f) 66 } 67 } 68 69 }