Fix/logx test log mismatchtime schedule num (#5305)

Co-authored-by: qiuwenhao <qiushaotest@qq.com>
This commit is contained in:
Qiu shao
2025-11-30 21:44:53 +08:00
committed by GitHub
parent fdf4ccf057
commit c6f75532fa
4 changed files with 6 additions and 15 deletions

View File

@@ -1,8 +1,6 @@
package fx package fx
import ( import (
"io"
"log"
"math/rand" "math/rand"
"reflect" "reflect"
"runtime" "runtime"
@@ -13,6 +11,7 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx/logtest"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
"go.uber.org/goleak" "go.uber.org/goleak"
) )
@@ -238,7 +237,7 @@ func TestLast(t *testing.T) {
func TestMap(t *testing.T) { func TestMap(t *testing.T) {
runCheckedTest(t, func(t *testing.T) { runCheckedTest(t, func(t *testing.T) {
log.SetOutput(io.Discard) logtest.Discard(t)
tests := []struct { tests := []struct {
mapper MapFunc mapper MapFunc

View File

@@ -4,8 +4,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"io"
"log"
"runtime" "runtime"
"sync/atomic" "sync/atomic"
"testing" "testing"
@@ -17,9 +15,6 @@ import (
var errDummy = errors.New("dummy") var errDummy = errors.New("dummy")
func init() {
log.SetOutput(io.Discard)
}
func TestFinish(t *testing.T) { func TestFinish(t *testing.T) {
defer goleak.VerifyNone(t) defer goleak.VerifyNone(t)

View File

@@ -1,13 +1,12 @@
package threading package threading
import ( import (
"io"
"log"
"sync" "sync"
"sync/atomic" "sync/atomic"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx/logtest"
) )
func TestRoutineGroupRun(t *testing.T) { func TestRoutineGroupRun(t *testing.T) {
@@ -25,8 +24,7 @@ func TestRoutineGroupRun(t *testing.T) {
} }
func TestRoutingGroupRunSafe(t *testing.T) { func TestRoutingGroupRunSafe(t *testing.T) {
log.SetOutput(io.Discard) logtest.Discard(t)
var count int32 var count int32
group := NewRoutineGroup() group := NewRoutineGroup()
var once sync.Once var once sync.Once

View File

@@ -3,13 +3,12 @@ package threading
import ( import (
"bytes" "bytes"
"context" "context"
"io"
"log"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/lang" "github.com/zeromicro/go-zero/core/lang"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/logx/logtest"
) )
func TestRoutineId(t *testing.T) { func TestRoutineId(t *testing.T) {
@@ -17,7 +16,7 @@ func TestRoutineId(t *testing.T) {
} }
func TestRunSafe(t *testing.T) { func TestRunSafe(t *testing.T) {
log.SetOutput(io.Discard) logtest.Discard(t)
i := 0 i := 0