feat(dingtalk): enable secure multimodal image QA
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package dingtalk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/im"
|
||||
)
|
||||
|
||||
type failingCardRoundTripper struct{}
|
||||
|
||||
func (failingCardRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
|
||||
return nil, errors.New("simulated delivery failure")
|
||||
}
|
||||
|
||||
func TestFinalizeStreamPropagatesCardDeliveryFailure(t *testing.T) {
|
||||
oldClient := httpClient
|
||||
httpClient = &http.Client{Transport: failingCardRoundTripper{}, Timeout: time.Second}
|
||||
t.Cleanup(func() { httpClient = oldClient })
|
||||
|
||||
adapter := &Adapter{
|
||||
clientID: "robot",
|
||||
token: "cached-token",
|
||||
tokenExpAt: time.Now().Add(time.Hour),
|
||||
}
|
||||
streamID := "dt:fail-closed-test"
|
||||
streamsMu.Lock()
|
||||
dStreams[streamID] = &streamState{outTrackID: "track-id", createdAt: time.Now()}
|
||||
streamsMu.Unlock()
|
||||
t.Cleanup(func() {
|
||||
streamsMu.Lock()
|
||||
delete(dStreams, streamID)
|
||||
streamsMu.Unlock()
|
||||
})
|
||||
|
||||
err := adapter.FinalizeStream(context.Background(), &im.IncomingMessage{}, streamID, "image recognition failed")
|
||||
if err == nil {
|
||||
t.Fatal("expected final card delivery failure to propagate")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user