feat: 算力引擎 Go 后端核心(new-api)
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/common"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestFormatUserLogsStripsQuotaSaturation verifies the admin-only quota
|
||||
// saturation marker (nested under other.admin_info) is removed for non-admin
|
||||
// log views, since formatUserLogs strips the whole admin_info object.
|
||||
func TestFormatUserLogsStripsQuotaSaturation(t *testing.T) {
|
||||
other := common.MapToJsonStr(map[string]interface{}{
|
||||
"model_price": 0.004,
|
||||
"admin_info": map[string]interface{}{
|
||||
"quota_saturation": map[string]interface{}{
|
||||
"op": "QuotaFromDecimal",
|
||||
"kind": "overflow",
|
||||
"clamped": common.MaxQuota,
|
||||
},
|
||||
},
|
||||
})
|
||||
logs := []*Log{{Other: other}}
|
||||
|
||||
formatUserLogs(logs, 0)
|
||||
|
||||
parsed, err := common.StrToMap(logs[0].Other)
|
||||
require.NoError(t, err)
|
||||
_, hasAdminInfo := parsed["admin_info"]
|
||||
require.False(t, hasAdminInfo, "admin_info (and nested quota_saturation) must be stripped for non-admin views")
|
||||
// Non-admin billing fields remain visible.
|
||||
require.Contains(t, parsed, "model_price")
|
||||
}
|
||||
Reference in New Issue
Block a user