test: add unit tests for billing, websearch, and notify systems

Billing (25 tests):
- CalculateCostUnified: nil resolver fallback, token/per_request/image modes
- GetModelPricingWithChannel: nil/partial/full channel overrides
- resolveAccountStatsCost: four-level priority chain integration tests

WebSearch (18 tests):
- PopulateWebSearchUsage: nil input, manager states, QuotaLimit nil/*int64
- ResetWebSearchUsage: nil manager error
- Manager.ResetUsage: nil Redis
- shouldEmulateWebSearch: full decision chain (8 scenarios)

Notify (36 tests):
- ParseNotifyEmails/MarshalNotifyEmails: old/new format, roundtrip
- crossedDownward: boundary values, threshold semantics
- checkQuotaDimCrossings: mixed dimensions, disabled/zero skip
This commit is contained in:
erio
2026-04-14 08:42:28 +08:00
parent 7c7292935e
commit 9028d2085f
8 changed files with 1369 additions and 0 deletions

View File

@@ -313,3 +313,11 @@ func TestNewHTTPClient_ValidSOCKS5Proxy(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, c)
}
// --- ResetUsage ---
func TestManager_ResetUsage_NilRedis(t *testing.T) {
m := NewManager(nil, nil)
err := m.ResetUsage(context.Background(), "brave")
require.NoError(t, err)
}