@ -22,6 +22,7 @@ import (
"compress/gzip"
"compress/gzip"
"io"
"io"
"io/ioutil"
"io/ioutil"
"log"
"os"
"os"
"path/filepath"
"path/filepath"
"runtime"
"runtime"
@ -280,6 +281,76 @@ icon: https://example.com/64x64.png
}
}
}
}
// Test the order of file loading. The Chart.yaml file needs to come first for
// later comparison checks. See https://github.com/helm/helm/pull/8948
func TestLoadFilesOrder ( t * testing . T ) {
goodFiles := [ ] * BufferedFile {
{
Name : "requirements.yaml" ,
Data : [ ] byte ( "dependencies:" ) ,
} ,
{
Name : "values.yaml" ,
Data : [ ] byte ( "var: some values" ) ,
} ,
{
Name : "templates/deployment.yaml" ,
Data : [ ] byte ( "some deployment" ) ,
} ,
{
Name : "templates/service.yaml" ,
Data : [ ] byte ( "some service" ) ,
} ,
{
Name : "Chart.yaml" ,
Data : [ ] byte ( ` apiVersion : v1
name : frobnitz
description : This is a frobnitz .
version : "1.2.3"
keywords :
- frobnitz
- sprocket
- dodad
maintainers :
- name : The Helm Team
email : helm @ example . com
- name : Someone Else
email : nobody @ example . com
sources :
- https : //example.com/foo/bar
home : http : //example.com
icon : https : //example.com/64x64.png
` ) ,
} ,
}
// Capture stderr to make sure message about Chart.yaml handle dependencies
// is not present
r , w , err := os . Pipe ( )
if err != nil {
t . Fatalf ( "Unable to create pipe: %s" , err )
}
stderr := log . Writer ( )
log . SetOutput ( w )
defer func ( ) {
log . SetOutput ( stderr )
} ( )
_ , err = LoadFiles ( goodFiles )
if err != nil {
t . Errorf ( "Expected good files to be loaded, got %v" , err )
}
w . Close ( )
var text bytes . Buffer
io . Copy ( & text , r )
if text . String ( ) != "" {
t . Errorf ( "Expected no message to Stderr, got %s" , text . String ( ) )
}
}
// Packaging the chart on a Windows machine will produce an
// Packaging the chart on a Windows machine will produce an
// archive that has \\ as delimiters. Test that we support these archives
// archive that has \\ as delimiters. Test that we support these archives
func TestLoadFileBackslash ( t * testing . T ) {
func TestLoadFileBackslash ( t * testing . T ) {