mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-09 00:30:28 +00:00
test(logging): add logtest.NewLogger (#1300)
Return a `Logger` and its recording `Handler` together, so tests no longer need the two-line setup. Stacked on https://gitea.com/gitea/runner/pulls/1295. Assisted-by: Codet Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1300 Reviewed-by: bircni <[email protected]>
This commit is contained in:
1 parent
de961b91eb
commit
3bc5cc03f8
7 files changed
+21
-32
No files matched your search
@@ -12,7 +12,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"gitea.com/gitea/runner/act/common"
|
||||
"gitea.com/gitea/runner/act/common/logging"
|
||||
"gitea.com/gitea/runner/act/common/logging/logtest"
|
||||
|
||||
"gitea.dev/actionslib/pkg/model"
|
||||
@@ -27,8 +26,7 @@ func unsecureRC() *RunContext {
|
||||
|
||||
func TestSetEnv(t *testing.T) {
|
||||
a := assert.New(t)
|
||||
hook := logtest.New()
|
||||
logger := logging.New(hook)
|
||||
logger, hook := logtest.NewLogger()
|
||||
ctx := common.WithLogger(context.Background(), logger)
|
||||
rc := unsecureRC()
|
||||
handler := rc.commandHandler(ctx)
|
||||
@@ -122,8 +120,7 @@ func TestAddpath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestStopCommands(t *testing.T) {
|
||||
hook := logtest.New()
|
||||
logger := logging.New(hook)
|
||||
logger, hook := logtest.NewLogger()
|
||||
|
||||
a := assert.New(t)
|
||||
ctx := common.WithLogger(context.Background(), logger)
|
||||
@@ -177,8 +174,7 @@ func TestAddpathADO(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAddmask(t *testing.T) {
|
||||
hook := logtest.New()
|
||||
logger := logging.New(hook)
|
||||
logger, hook := logtest.NewLogger()
|
||||
|
||||
a := assert.New(t)
|
||||
ctx := context.Background()
|
||||
|
||||
Reference in new issue
Block a user