feat: add unit tests for COS object name parsing and enhance error handling

This commit introduces unit tests for the `parseCosObjectName` method in the `cosFileService`, ensuring it correctly rejects local scheme URLs and properly parses COS scheme URLs. Additionally, the `parseCosObjectName` method has been updated to return an error for unsupported schemes, improving error handling in the `GetFile` and `DeleteFile` methods. This enhancement ensures more robust handling of file paths in the application.
This commit is contained in:
wizardchen
2026-05-29 12:21:17 +08:00
committed by lyingbug
parent 83808cc5b7
commit 5d02404fdd
5 changed files with 167 additions and 36 deletions
+2 -4
View File
@@ -9,7 +9,6 @@ import (
"github.com/Tencent/WeKnora/internal/logger"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"github.com/redis/go-redis/v9"
)
@@ -44,9 +43,8 @@ type qaRequest struct {
channel *IMChannel
channelID string
// fileSvc resolves storage URLs to HTTP URLs for the tenant's storage backend.
// May be nil if the tenant has no storage config.
fileSvc interfaces.FileService
// tenant is used to resolve provider:// URLs in outbound replies (scheme-aware).
tenant *types.Tenant
// userKey is "channelID:userID:chatID", used for per-user limits and /stop.
userKey string