test: forward-port regression test from Helm 2 (#7927)

Signed-off-by: Matt Butcher <matt.butcher@microsoft.com>
pull/7653/head
Matt Butcher 4 years ago committed by GitHub
parent a3fa01ff8b
commit 549193dbcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,9 +17,12 @@ limitations under the License.
package lint
import (
"io/ioutil"
"os"
"strings"
"testing"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/lint/support"
)
@ -104,3 +107,30 @@ func TestGoodChart(t *testing.T) {
t.Errorf("All failed but shouldn't have: %#v", m)
}
}
// TestHelmCreateChart tests that a `helm create` always passes a `helm lint` test.
//
// See https://github.com/helm/helm/issues/7923
func TestHelmCreateChart(t *testing.T) {
dir, err := ioutil.TempDir("", "-helm-test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
createdChart, err := chartutil.Create("testhelmcreatepasseslint", dir)
if err != nil {
t.Error(err)
// Fatal is bad because of the defer.
return
}
// Note: we test with strict=true here, even though others have
// strict = false.
m := All(createdChart, values, namespace, true).Messages
if ll := len(m); ll != 1 {
t.Errorf("All should have had exactly 1 error. Got %d", ll)
} else if msg := m[0].Err.Error(); !strings.Contains(msg, "icon is recommended") {
t.Errorf("Unexpected lint error: %s", msg)
}
}

Loading…
Cancel
Save