summaryrefslogtreecommitdiffstats
path: root/pkg/runner/runner_test.go
diff options
context:
space:
mode:
authorChristopherHX <christopher.homberger@web.de>2022-12-09 11:25:32 +0100
committerGitHub <noreply@github.com>2022-12-09 11:25:32 +0100
commit7d9951200f366ee7a207844e185bf5de7e3f7ab5 (patch)
tree522938410b0c1971aec0fad74bcf45fa5443b701 /pkg/runner/runner_test.go
parentfix: handle env-vars case sensitive (#1493) (diff)
downloadforgejo-act-7d9951200f366ee7a207844e185bf5de7e3f7ab5.tar.xz
forgejo-act-7d9951200f366ee7a207844e185bf5de7e3f7ab5.zip
feat: JobLoggerFactory (#1496)
Remove overriding io.Stdout in TestMaskValues to prevent deadlock in GitHub Actions
Diffstat (limited to 'pkg/runner/runner_test.go')
-rw-r--r--pkg/runner/runner_test.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go
index 21b584f..faa13ce 100644
--- a/pkg/runner/runner_test.go
+++ b/pkg/runner/runner_test.go
@@ -1,8 +1,10 @@
package runner
import (
+ "bytes"
"context"
"fmt"
+ "io"
"os"
"path/filepath"
"runtime"
@@ -343,6 +345,17 @@ func TestRunDifferentArchitecture(t *testing.T) {
tjfi.runTest(context.Background(), t, &Config{ContainerArchitecture: "linux/arm64"})
}
+type maskJobLoggerFactory struct {
+ Output bytes.Buffer
+}
+
+func (f *maskJobLoggerFactory) WithJobLogger() *log.Logger {
+ logger := log.New()
+ logger.SetOutput(io.MultiWriter(&f.Output, os.Stdout))
+ logger.SetLevel(log.DebugLevel)
+ return logger
+}
+
func TestMaskValues(t *testing.T) {
assertNoSecret := func(text string, secret string) {
index := strings.Index(text, "composite secret")
@@ -366,9 +379,9 @@ func TestMaskValues(t *testing.T) {
platforms: platforms,
}
- output := captureOutput(t, func() {
- tjfi.runTest(context.Background(), t, &Config{})
- })
+ logger := &maskJobLoggerFactory{}
+ tjfi.runTest(WithJobLoggerFactory(common.WithLogger(context.Background(), logger.WithJobLogger()), logger), t, &Config{})
+ output := logger.Output.String()
assertNoSecret(output, "secret value")
assertNoSecret(output, "YWJjCg==")