Files
Atlas/internal/service/asset/url_test.go
T
renjue f920f465ed
CI / docker (push) Successful in 2m28s
实现 Atlas AI 平台一期能力并完成品牌化改造。
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 23:22:19 +08:00

33 lines
996 B
Go

package asset
import "testing"
func TestResolvePublicFileURLs(t *testing.T) {
params := map[string]any{
"image": "/api/v1/user/files/1?exp=1&sig=abc",
"prompt": "cat",
"refs": []any{"/api/v1/user/files/2?exp=1&sig=def"},
}
ResolvePublicFileURLs(params, "https://atlas.example.com")
if params["image"] != "https://atlas.example.com/api/v1/user/files/1?exp=1&sig=abc" {
t.Fatalf("unexpected image url: %v", params["image"])
}
if params["prompt"] != "cat" {
t.Fatalf("prompt should be unchanged")
}
refs, ok := params["refs"].([]any)
if !ok || refs[0] != "https://atlas.example.com/api/v1/user/files/2?exp=1&sig=def" {
t.Fatalf("unexpected refs: %v", params["refs"])
}
}
func TestResolvePublicFileURLsSkipsAbsolute(t *testing.T) {
params := map[string]any{
"image": "https://cdn.example.com/a.png",
}
ResolvePublicFileURLs(params, "https://atlas.example.com")
if params["image"] != "https://cdn.example.com/a.png" {
t.Fatalf("absolute url should be unchanged")
}
}