mirror of https://github.com/helm/helm.git
fix(*): fixed tests for Windows
This commit is contained in:
parent
aec6c50708
commit
f3b205c6ef
|
@ -1,8 +1,10 @@
|
|||
.DS_Store
|
||||
.coverage/
|
||||
.vimrc
|
||||
.vscode/
|
||||
_dist/
|
||||
_proto/*.pb.go
|
||||
bin/
|
||||
rootfs/tiller
|
||||
vendor/
|
||||
*.exe
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package helmpath
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHelmHome(t *testing.T) {
|
||||
hh := Home("/r")
|
||||
isEq := func(t *testing.T, a, b string) {
|
||||
if a != b {
|
||||
t.Errorf("Expected %q, got %q", a, b)
|
||||
}
|
||||
}
|
||||
|
||||
isEq(t, hh.String(), "/r")
|
||||
isEq(t, hh.Repository(), "/r/repository")
|
||||
isEq(t, hh.RepositoryFile(), "/r/repository/repositories.yaml")
|
||||
isEq(t, hh.LocalRepository(), "/r/repository/local")
|
||||
isEq(t, hh.Cache(), "/r/repository/cache")
|
||||
isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml")
|
||||
isEq(t, hh.Starters(), "/r/starters")
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||
// +build !windows
|
||||
|
||||
package helmpath
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHelmHome(t *testing.T) {
|
||||
hh := Home("/r")
|
||||
isEq := func(t *testing.T, a, b string) {
|
||||
if a != b {
|
||||
t.Error(runtime.GOOS)
|
||||
t.Errorf("Expected %q, got %q", a, b)
|
||||
}
|
||||
}
|
||||
|
||||
isEq(t, hh.String(), "/r")
|
||||
isEq(t, hh.Repository(), "/r/repository")
|
||||
isEq(t, hh.RepositoryFile(), "/r/repository/repositories.yaml")
|
||||
isEq(t, hh.LocalRepository(), "/r/repository/local")
|
||||
isEq(t, hh.Cache(), "/r/repository/cache")
|
||||
isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml")
|
||||
isEq(t, hh.Starters(), "/r/starters")
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2016 The Kubernetes Authors All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build windows
|
||||
|
||||
package helmpath
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHelmHome(t *testing.T) {
|
||||
hh := Home("r:\\")
|
||||
isEq := func(t *testing.T, a, b string) {
|
||||
if a != b {
|
||||
t.Errorf("Expected %q, got %q", b, a)
|
||||
}
|
||||
}
|
||||
|
||||
isEq(t, hh.String(), "r:\\")
|
||||
isEq(t, hh.Repository(), "r:\\repository")
|
||||
isEq(t, hh.RepositoryFile(), "r:\\repository\\repositories.yaml")
|
||||
isEq(t, hh.LocalRepository(), "r:\\repository\\local")
|
||||
isEq(t, hh.Cache(), "r:\\repository\\cache")
|
||||
isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml")
|
||||
isEq(t, hh.Starters(), "r:\\starters")
|
||||
}
|
|
@ -49,14 +49,14 @@ func TestInspect(t *testing.T) {
|
|||
}
|
||||
|
||||
expect := []string{
|
||||
strings.TrimSpace(string(cdata)),
|
||||
strings.TrimSpace(string(data)),
|
||||
strings.Replace(strings.TrimSpace(string(cdata)), "\r", "", -1),
|
||||
strings.Replace(strings.TrimSpace(string(data)), "\r", "", -1),
|
||||
}
|
||||
|
||||
// Problem: ghodss/yaml doesn't marshal into struct order. To solve, we
|
||||
// have to carefully craft the Chart.yaml to match.
|
||||
for i, got := range parts {
|
||||
got = strings.TrimSpace(got)
|
||||
got = strings.Replace(strings.TrimSpace(got), "\r", "", -1)
|
||||
if got != expect[i] {
|
||||
t.Errorf("Expected\n%q\nGot\n%q\n", expect[i], got)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"bytes"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -121,11 +122,16 @@ func TestLoadPlugins(t *testing.T) {
|
|||
if pp.Long != tt.long {
|
||||
t.Errorf("%d: Expected Use=%q, got %q", i, tt.long, pp.Long)
|
||||
}
|
||||
if err := pp.RunE(pp, tt.args); err != nil {
|
||||
t.Errorf("Error running %s: %s", tt.use, err)
|
||||
}
|
||||
if out.String() != tt.expect {
|
||||
t.Errorf("Expected %s to output:\n%s\ngot\n%s", tt.use, tt.expect, out.String())
|
||||
|
||||
// Currently, plugins assume a Linux subsystem. Skip the execution
|
||||
// tests until this is fixed
|
||||
if runtime.GOOS != "windows" {
|
||||
if err := pp.RunE(pp, tt.args); err != nil {
|
||||
t.Errorf("Error running %s: %s", tt.use, err)
|
||||
}
|
||||
if out.String() != tt.expect {
|
||||
t.Errorf("Expected %s to output:\n%s\ngot\n%s", tt.use, tt.expect, out.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ package search
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"path"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
@ -70,7 +70,9 @@ func (i *Index) AddRepo(rname string, ind *repo.IndexFile, all bool) {
|
|||
// By convention, an index file is supposed to have the newest at the
|
||||
// 0 slot, so our best bet is to grab the 0 entry and build the index
|
||||
// entry off of that.
|
||||
fname := filepath.Join(rname, name)
|
||||
// Note: Do not use filePath.Join since on Windows it will return \
|
||||
// which results in a repo name that cannot be understood.
|
||||
fname := path.Join(rname, name)
|
||||
if !all {
|
||||
i.lines[fname] = indstr(rname, ref[0])
|
||||
i.charts[fname] = ref[0]
|
||||
|
|
|
@ -17,10 +17,22 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVerifyCmd(t *testing.T) {
|
||||
|
||||
stat_exe := "stat"
|
||||
stat_path_msg := "no such file or directory"
|
||||
stat_file_msg := stat_path_msg
|
||||
if runtime.GOOS == "windows" {
|
||||
stat_exe = "GetFileAttributesEx"
|
||||
stat_path_msg = "The system cannot find the path specified."
|
||||
stat_file_msg = "The system cannot find the file specified."
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
|
@ -36,7 +48,7 @@ func TestVerifyCmd(t *testing.T) {
|
|||
{
|
||||
name: "verify requires that chart exists",
|
||||
args: []string{"no/such/file"},
|
||||
expect: "stat no/such/file: no such file or directory",
|
||||
expect: fmt.Sprintf("%s no/such/file: %s", stat_exe, stat_path_msg),
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
|
@ -48,7 +60,7 @@ func TestVerifyCmd(t *testing.T) {
|
|||
{
|
||||
name: "verify requires that chart has prov file",
|
||||
args: []string{"testdata/testcharts/compressedchart-0.1.0.tgz"},
|
||||
expect: "could not load provenance file testdata/testcharts/compressedchart-0.1.0.tgz.prov: stat testdata/testcharts/compressedchart-0.1.0.tgz.prov: no such file or directory",
|
||||
expect: fmt.Sprintf("could not load provenance file testdata/testcharts/compressedchart-0.1.0.tgz.prov: %s testdata/testcharts/compressedchart-0.1.0.tgz.prov: %s", stat_exe, stat_file_msg),
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -229,6 +229,10 @@ func LoadDir(dir string) (*chart.Chart, error) {
|
|||
|
||||
err = filepath.Walk(topdir, func(name string, fi os.FileInfo, err error) error {
|
||||
n := strings.TrimPrefix(name, topdir)
|
||||
|
||||
// Normalize to / since it will also work on Windows
|
||||
n = filepath.ToSlash(n)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
|
@ -735,7 +735,8 @@ func (s *ReleaseServer) renderResources(ch *chart.Chart, values chartutil.Values
|
|||
for k, v := range files {
|
||||
if strings.HasSuffix(k, notesFileSuffix) {
|
||||
// Only apply the notes if it belongs to the parent chart
|
||||
if k == filepath.Join(ch.Metadata.Name, "templates", notesFileSuffix) {
|
||||
// Note: Do not use filePath.Join since it creates a path with \ which is not expected
|
||||
if k == path.Join(ch.Metadata.Name, "templates", notesFileSuffix) {
|
||||
notes = v
|
||||
}
|
||||
delete(files, k)
|
||||
|
|
Loading…
Reference in New Issue