Merge pull request #1671 from vdice/add-newline-fetch-verify

feat(helm): add newline to fetch --verify output
pull/1680/head
Adam Reese 8 years ago committed by GitHub
commit 4b20ef7699

@ -124,7 +124,7 @@ func (f *fetchCmd) run() error {
}
if f.verify {
fmt.Fprintf(f.out, "Verification: %v", v)
fmt.Fprintf(f.out, "Verification: %v\n", v)
}
// After verification, untar the chart into the requested directory.

@ -18,8 +18,10 @@ package main
import (
"bytes"
"fmt"
"os"
"path/filepath"
"regexp"
"testing"
"k8s.io/helm/pkg/repo/repotest"
@ -46,6 +48,7 @@ func TestFetchCmd(t *testing.T) {
failExpect string
expectFile string
expectDir bool
expectVerify bool
}{
{
name: "Basic chart fetch",
@ -76,6 +79,7 @@ func TestFetchCmd(t *testing.T) {
chart: "test/signtest",
flags: []string{"--verify", "--keyring", "testdata/helm-test-key.pub"},
expectFile: "./signtest-0.1.0.tgz",
expectVerify: true,
},
{
name: "Fetch and fail verify",
@ -87,7 +91,7 @@ func TestFetchCmd(t *testing.T) {
{
name: "Fetch and untar",
chart: "test/signtest",
flags: []string{"--verify", "--keyring", "testdata/helm-test-key.pub", "--untar", "--untardir", "signtest"},
flags: []string{"--untar", "--untardir", "signtest"},
expectFile: "./signtest",
expectDir: true,
},
@ -97,6 +101,7 @@ func TestFetchCmd(t *testing.T) {
flags: []string{"--verify", "--keyring", "testdata/helm-test-key.pub", "--untar", "--untardir", "signtest"},
expectFile: "./signtest",
expectDir: true,
expectVerify: true,
},
}
@ -126,6 +131,15 @@ func TestFetchCmd(t *testing.T) {
t.Errorf("%q reported error: %s", tt.name, err)
continue
}
if tt.expectVerify {
pointerAddressPattern := "0[xX][A-Fa-f0-9]+"
sha256Pattern := "[A-Fa-f0-9]{64}"
verificationRegex := regexp.MustCompile(
fmt.Sprintf("Verification: &{%s sha256:%s signtest-0.1.0.tgz}\n", pointerAddressPattern, sha256Pattern))
if !verificationRegex.MatchString(buf.String()) {
t.Errorf("%q: expected match for regex %s, got %s", tt.name, verificationRegex, buf.String())
}
}
ef := filepath.Join(outdir, tt.expectFile)
fi, err := os.Stat(ef)

Loading…
Cancel
Save