|
|
|
@ -17,13 +17,14 @@ limitations under the License.
|
|
|
|
|
package chart
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/base64"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/ioutil"
|
|
|
|
|
"path/filepath"
|
|
|
|
|
"reflect"
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/kubernetes/helm/pkg/log"
|
|
|
|
|
"github.com/kubernetes/helm/pkg/util"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
@ -202,7 +203,7 @@ func findMember(root, path string, members []*Member) error {
|
|
|
|
|
for _, member := range members {
|
|
|
|
|
if member.Path == path {
|
|
|
|
|
filename := filepath.Join(root, path)
|
|
|
|
|
if err := compareContent(filename, string(member.Content)); err != nil {
|
|
|
|
|
if err := compareContent(filename, member.Content); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -233,20 +234,52 @@ func TestLoadMember(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filename := filepath.Join(c.loader.dir(), testmember)
|
|
|
|
|
if err := compareContent(filename, string(member.Content)); err != nil {
|
|
|
|
|
if err := compareContent(filename, member.Content); err != nil {
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func compareContent(filename, content string) error {
|
|
|
|
|
b, err := ioutil.ReadFile(filename)
|
|
|
|
|
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%v\nhave:\n%v\n", member.Path, want, have)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func compareContent(filename string, content []byte) error {
|
|
|
|
|
compare, err := ioutil.ReadFile(filename)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("Cannot read test file %s: %s", filename, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
compare := base64.StdEncoding.EncodeToString(b)
|
|
|
|
|
if content != compare {
|
|
|
|
|
return fmt.Errorf("Expected member content\n%v\ngot\n%v", []byte(compare), []byte(content))
|
|
|
|
|
if !reflect.DeepEqual(compare, content) {
|
|
|
|
|
return fmt.Errorf("Expected member content\n%v\ngot\n%v", compare, content)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|