Skip to content

Commit

Permalink
test: discard Repo Server logs in stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed Jan 23, 2024
1 parent e2b7c66 commit a5eb4c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions native/internal/helm/repotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package helm

import (
"github.com/orcaman/concurrent-map/v2"
"github.com/sirupsen/logrus"
"helm.sh/helm/v3/pkg/repo/repotest"
"io"
"net/http"
"os"
"testing"
Expand All @@ -18,10 +20,12 @@ type RepoServerOptions struct {
}

func RepoServerStart(options *RepoServerOptions) (*repotest.Server, error) {
logrus.SetOutput(io.Discard)
server, err := repotest.NewTempServerWithCleanup(&testing.T{}, options.Glob)
if err != nil {
return nil, err
}
logrus.SetLevel(logrus.ErrorLevel)
if len(options.Username) > 0 && len(options.Password) > 0 {
server.Stop()
server.WithMiddleware(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -37,6 +41,7 @@ func RepoServerStart(options *RepoServerOptions) (*repotest.Server, error) {
}

func RepoOciServerStart(options *RepoServerOptions) (*repotest.OCIServer, error) {
logrus.SetOutput(io.Discard)
tdir, err := os.MkdirTemp("", "helm-repotest-")
server, err := repotest.NewOCIServer(&testing.T{}, tdir)
if err != nil {
Expand Down

0 comments on commit a5eb4c2

Please sign in to comment.