Merge pull request #8159 from adamreese/ref/chartutils-fixtures

ref(pkg/chartutil): use minimal in-memory fixtures
pull/8189/head
Adam Reese 5 years ago committed by GitHub
commit 728eecbdf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,6 +21,8 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"helm.sh/helm/v3/pkg/chart"
)
// ref: http://www.yaml.org/spec/1.2/spec.html#id2803362
@ -55,9 +57,48 @@ pequod:
bar: null
`)
func withDeps(c *chart.Chart, deps ...*chart.Chart) *chart.Chart {
c.AddDependency(deps...)
return c
}
func TestCoalesceValues(t *testing.T) {
is := assert.New(t)
c := loadChart(t, "testdata/moby")
c := withDeps(&chart.Chart{
Metadata: &chart.Metadata{Name: "moby"},
Values: map[string]interface{}{
"back": "exists",
"bottom": "exists",
"front": "exists",
"left": "exists",
"name": "moby",
"nested": map[string]interface{}{"boat": true},
"override": "bad",
"right": "exists",
"scope": "moby",
"top": "nope",
},
},
withDeps(&chart.Chart{
Metadata: &chart.Metadata{Name: "pequod"},
Values: map[string]interface{}{"name": "pequod", "scope": "pequod"},
},
&chart.Chart{
Metadata: &chart.Metadata{Name: "ahab"},
Values: map[string]interface{}{
"scope": "ahab",
"name": "ahab",
"boat": true,
"nested": map[string]interface{}{"foo": false, "bar": true},
},
},
),
&chart.Chart{
Metadata: &chart.Metadata{Name: "spouter"},
Values: map[string]interface{}{"scope": "spouter"},
},
)
vals, err := ReadValues(testCoalesceValuesYaml)
if err != nil {

@ -81,7 +81,7 @@ func TestCreateFrom(t *testing.T) {
Name: "foo",
Version: "0.1.0",
}
srcdir := "./testdata/mariner"
srcdir := "./testdata/frobnitz/charts/mariner"
if err := CreateFrom(cf, tdir, srcdir); err != nil {
t.Fatal(err)

@ -1,8 +0,0 @@
dependencies:
- name: alpine
version: "0.1.0"
repository: https://example.com/charts
- name: mariner
version: "4.3.2"
repository: https://example.com/charts
digest: invalid

@ -1,27 +0,0 @@
apiVersion: v1
name: frobnitz_backslash
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
annotations:
extrakey: extravalue
anotherkey: anothervalue
dependencies:
- name: alpine
version: "0.1.0"
repository: https://example.com/charts
- name: mariner
version: "4.3.2"
repository: https://example.com/charts

@ -1 +0,0 @@
This is an install document. The client may display this.

@ -1 +0,0 @@
LICENSE placeholder.

@ -1,11 +0,0 @@
# Frobnitz
This is an example chart.
## Usage
This is an example. It has no usage.
## Development
For developer info, see the top-level repository.

@ -1 +0,0 @@
This should be ignored by the loader, but may be included in a chart.

@ -1,5 +0,0 @@
apiVersion: v1
name: alpine
description: Deploy a basic Alpine Linux pod
version: 0.1.0
home: https://helm.sh/helm

@ -1,9 +0,0 @@
This example was generated using the command `helm create alpine`.
The `templates/` directory contains a very simple pod resource with a
couple of parameters.
The `values.toml` file contains the default values for the
`alpine-pod.yaml` template.
You can install this example using `helm install ./alpine`.

@ -1,5 +0,0 @@
apiVersion: v1
name: mast1
description: A Helm chart for Kubernetes
version: 0.1.0
home: ""

@ -1,4 +0,0 @@
# Default values for mast1.
# This is a YAML-formatted file.
# Declare name/value pairs to be passed into your templates.
# name = "value"

@ -1,14 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: {{.Release.Name}}-{{.Chart.Name}}
labels:
app.kubernetes.io/managed-by: {{.Release.Service}}
chartName: {{.Chart.Name}}
chartVersion: {{.Chart.Version | quote}}
spec:
restartPolicy: {{default "Never" .restart_policy}}
containers:
- name: waiter
image: "alpine:3.3"
command: ["/bin/sleep","9000"]

@ -1,2 +0,0 @@
# The pod name
name: "my-alpine"

@ -1 +0,0 @@
This is a placeholder for documentation.

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
version="1.0" width="256" height="256" id="test">
<desc>Example icon</desc>
<rect id="first" x="2" y="2" width="40" height="60" fill="navy"/>
<rect id="second" x="15" y="4" width="40" height="60" fill="red"/>
</svg>

Before

Width:  |  Height:  |  Size: 374 B

@ -1 +0,0 @@
Hello {{.Name | default "world"}}

@ -1,6 +0,0 @@
# A values file contains configuration.
name: "Some Name"
section:
name: "Name in a section"

@ -1,4 +0,0 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: moby
version: 0.1.0

@ -1,4 +0,0 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: pequod
version: 0.1.0

@ -1,4 +0,0 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: ahab
version: 0.1.0

@ -1,6 +0,0 @@
scope: ahab
name: ahab
boat: true
nested:
foo: false
bar: true

@ -1,2 +0,0 @@
scope: pequod
name: pequod

@ -1,4 +0,0 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: spouter
version: 0.1.0

@ -1,11 +0,0 @@
scope: moby
name: moby
override: bad
top: nope
bottom: exists
right: exists
left: exists
front: exists
back: exists
nested:
boat: true
Loading…
Cancel
Save