Commit 100dd3b0 authored by jackgr's avatar jackgr

Add chart content test

parent cbe756cb
......@@ -21,9 +21,11 @@ import (
"fmt"
"io/ioutil"
"path/filepath"
"reflect"
"testing"
"github.com/kubernetes/helm/pkg/log"
"github.com/kubernetes/helm/pkg/util"
)
const (
......@@ -238,6 +240,39 @@ func TestLoadMember(t *testing.T) {
}
}
func TestLoadContent(t *testing.T) {
c, err := LoadDir(testdir)
if err != nil {
t.Errorf("Failed to load chart: %s", err)
}
content, err := c.LoadContent()
if err != nil {
t.Errorf("Failed to load chart content: %s", err)
}
want := c.Chartfile()
have := content.Chartfile
if !reflect.DeepEqual(want, have) {
t.Errorf("Unexpected chart file\nwant:\n%s\nhave:\n%s\n",
util.ToYAMLOrError(want), util.ToYAMLOrError(have))
}
for _, member := range content.Members {
have := member.Content
wantMember, err := c.LoadMember(member.Path)
if err != nil {
t.Errorf("Failed to load chart member: %s", err)
}
t.Logf("%s:\n%s\n\n", member.Path, member.Content)
want := wantMember.Content
if !reflect.DeepEqual(want, have) {
t.Errorf("Unexpected chart member %s\nwant:\n%s\nhave:\n%s\n", member.Path, want, have)
}
}
}
func compareContent(filename, content string) error {
b, err := ioutil.ReadFile(filename)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment