28e53d90fc
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
32 lines
760 B
Go
32 lines
760 B
Go
package kitutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestErrorHooksRemainDistinct(t *testing.T) {
|
|
previousError := logError.Load()
|
|
previousSystemError := logSystemError.Load()
|
|
t.Cleanup(func() {
|
|
logError.Store(previousError)
|
|
logSystemError.Store(previousSystemError)
|
|
})
|
|
|
|
var ordinaryMessages []string
|
|
var systemMessages []string
|
|
SetLogging(nil, func(message string) {
|
|
ordinaryMessages = append(ordinaryMessages, message)
|
|
})
|
|
SetSystemErrorLogging(func(message string) {
|
|
systemMessages = append(systemMessages, message)
|
|
})
|
|
|
|
LogError("invalid dto")
|
|
LogSystemError("converter failure")
|
|
|
|
assert.Equal(t, []string{"invalid dto"}, ordinaryMessages)
|
|
assert.Equal(t, []string{"converter failure"}, systemMessages)
|
|
}
|