fix(tests): update resource alias syntax from 'res:' to 'res://' in tests and registry

Refactor tests and registry to use the new 'res://' syntax for resource aliases, ensuring consistency across the codebase. This change addresses alias handling in various test cases, including stream processing and registry encoding, to prevent data loss and improve resource reference management.
This commit is contained in:
wizardchen
2026-07-15 16:55:39 +08:00
committed by lyingbug
parent 38c594aec3
commit 0f4500b98f
4 changed files with 22 additions and 19 deletions
@@ -80,19 +80,19 @@ func (s *stubModelService) GetChatModel(context.Context, string) (chat.Chat, err
// TestStreamFlushesHeldAliasOnCancel verifies that when the request is cancelled
// mid-stream, the decoder's held-back alias suffix is flushed (emitted) rather
// than silently dropped. Without the ctx.Done() flush, "res:0" would be lost.
// than silently dropped. Without the ctx.Done() flush, "res://0" would be lost.
func TestStreamFlushesHeldAliasOnCancel(t *testing.T) {
const ref = "resource://AbCdEfGhIjKlMnOpQrStUv"
bus := &syncEventBus{}
model := &openStreamChat{chunks: []types.StreamResponse{
// Ends with a partial alias prefix ("res:0"), so the stream decoder
// Ends with a partial alias prefix ("res://0"), so the stream decoder
// holds it back waiting for the rest that never arrives before cancel.
{ResponseType: types.ResponseTypeAnswer, Content: "hello res:0"},
{ResponseType: types.ResponseTypeAnswer, Content: "hello res://0"},
}}
chatManage := &types.ChatManage{}
chatManage.SessionID = "sess-cancel"
chatManage.UserContent = ref // seeds the registry so res:0001 becomes a known alias
chatManage.UserContent = ref // seeds the registry so res://0001 becomes a known alias
chatManage.EventBus = bus
ctx, cancel := context.WithCancel(context.Background())
@@ -111,10 +111,10 @@ func TestStreamFlushesHeldAliasOnCancel(t *testing.T) {
cancel()
// After cancel, the held "res:0" suffix must be flushed as a final-answer chunk.
// After cancel, the held "res://0" suffix must be flushed as a final-answer chunk.
require.Eventually(t, func() bool {
for _, c := range bus.finalAnswerContents() {
if c == "res:0" {
if c == "res://0" {
return true
}
}