From f4bb9f56352c15b828e3be4eb092e606a048121e Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Wed, 15 Sep 2021 13:31:20 +0800 Subject: [PATCH] fix test error on ubuntu (#1048) --- core/logx/rotatelogger_test.go | 9 ++++++++- core/stat/internal/cpu_other.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/logx/rotatelogger_test.go b/core/logx/rotatelogger_test.go index 929b5c0b..c7439545 100644 --- a/core/logx/rotatelogger_test.go +++ b/core/logx/rotatelogger_test.go @@ -3,6 +3,7 @@ package logx import ( "os" "path/filepath" + "syscall" "testing" "time" @@ -97,7 +98,13 @@ func TestRotateLoggerRotate(t *testing.T) { }() } err = logger.rotate() - assert.Nil(t, err) + switch v := err.(type) { + case *os.LinkError: + // avoid rename error on ubuntu + assert.Equal(t, syscall.EXDEV, v.Err) + default: + assert.Nil(t, err) + } } func TestRotateLoggerWrite(t *testing.T) { diff --git a/core/stat/internal/cpu_other.go b/core/stat/internal/cpu_other.go index ddc33072..700f0f09 100644 --- a/core/stat/internal/cpu_other.go +++ b/core/stat/internal/cpu_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package internal