mirror of
https://github.com/helm/helm.git
synced 2026-08-12 22:16:30 +00:00
Added tests for PR 8948
LoadFiles needs to load the Chart.yaml file first. When later files are loaded there are checks for metadata. If that is not loaded the checks could be handled incorrectly. Signed-off-by: Matt Farina <matt@mattfarina.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"compress/gzip"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"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
|
||||
// archive that has \\ as delimiters. Test that we support these archives
|
||||
func TestLoadFileBackslash(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user