mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 03:29:45 +02:00
Prevent excessive log in tests
I had been unhappy with the fact that our go-test output had a lot of debug log messages which obfuscated test results. I'm finally removeing all those by directing the test log output to io.Discard. Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
@@ -1,31 +1,27 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"go.uber.org/zap"
|
||||
|
||||
ffs "github.com/helmfile/helmfile/pkg/filesystem"
|
||||
"github.com/helmfile/helmfile/pkg/helmexec"
|
||||
"github.com/helmfile/helmfile/pkg/remote"
|
||||
)
|
||||
|
||||
func newLoader() *EnvironmentValuesLoader {
|
||||
log, err := zap.NewDevelopment(zap.AddStacktrace(zap.DebugLevel))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
sugar := log.Sugar()
|
||||
log := helmexec.NewLogger(io.Discard, "debug")
|
||||
|
||||
storage := &Storage{
|
||||
FilePath: "./helmfile.yaml",
|
||||
basePath: ".",
|
||||
fs: ffs.DefaultFileSystem(),
|
||||
logger: sugar,
|
||||
logger: log,
|
||||
}
|
||||
|
||||
return NewEnvironmentValuesLoader(storage, storage.fs, sugar, remote.NewRemote(sugar, "/tmp", storage.fs))
|
||||
return NewEnvironmentValuesLoader(storage, storage.fs, log, remote.NewRemote(log, "/tmp", storage.fs))
|
||||
}
|
||||
|
||||
// See https://github.com/roboll/helmfile/pull/1169
|
||||
|
||||
@@ -2,6 +2,7 @@ package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -12,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGoGetter(t *testing.T) {
|
||||
logger := helmexec.NewLogger(os.Stderr, "warn")
|
||||
logger := helmexec.NewLogger(io.Discard, "warn")
|
||||
|
||||
testcases := []struct {
|
||||
chart, dir string
|
||||
|
||||
@@ -2,6 +2,7 @@ package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
"github.com/helmfile/helmfile/pkg/testhelper"
|
||||
)
|
||||
|
||||
var logger = helmexec.NewLogger(os.Stdout, "warn")
|
||||
var logger = helmexec.NewLogger(io.Discard, "warn")
|
||||
var valsRuntime, _ = vals.New(vals.Options{CacheSize: 32})
|
||||
|
||||
func injectFs(st *HelmState, fs *testhelper.TestFs) *HelmState {
|
||||
@@ -1914,7 +1915,7 @@ generated: 2019-05-16T15:42:45.50486+09:00
|
||||
return generatedDir, nil
|
||||
}
|
||||
|
||||
logger := helmexec.NewLogger(os.Stderr, "debug")
|
||||
logger := helmexec.NewLogger(io.Discard, "debug")
|
||||
basePath := "/src"
|
||||
state := &HelmState{
|
||||
basePath: basePath,
|
||||
@@ -1980,7 +1981,7 @@ generated: 2019-05-16T15:42:45.50486+09:00
|
||||
}
|
||||
|
||||
func TestHelmState_ResolveDeps_NoLockFile(t *testing.T) {
|
||||
logger := helmexec.NewLogger(os.Stderr, "debug")
|
||||
logger := helmexec.NewLogger(io.Discard, "debug")
|
||||
state := &HelmState{
|
||||
basePath: "/src",
|
||||
FilePath: "/src/helmfile.yaml",
|
||||
|
||||
@@ -2,7 +2,7 @@ package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"io"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestStorage_resolveFile(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
st := NewStorage(cacheDir, helmexec.NewLogger(os.Stderr, "debug"), filesystem.DefaultFileSystem())
|
||||
st := NewStorage(cacheDir, helmexec.NewLogger(io.Discard, "debug"), filesystem.DefaultFileSystem())
|
||||
|
||||
files, skipped, err := st.resolveFile(tt.args.missingFileHandler, tt.args.title, tt.args.path)
|
||||
if (err != nil) != tt.wantErr {
|
||||
|
||||
Reference in New Issue
Block a user