fix(plugin): 万相3.0视频 - 修复上游响应错误解析
This commit is contained in:
1 parent
24762eafa4
commit
534bb557e5
2 files changed
+60
-14
No files matched your search
@@ -1,6 +1,9 @@
|
||||
package app
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestProviderFailureDetailsReadsTopLevelModerationError(t *testing.T) {
|
||||
code, message := providerFailureDetails(map[string]any{
|
||||
@@ -59,3 +62,30 @@ func TestProviderPayloadBusinessFailureAcceptsStringSuccessCode(t *testing.T) {
|
||||
t.Fatalf("success payload was marked failed: (%q, %q)", code, message)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderPayloadBusinessFailureReadsNestedOutputFailure(t *testing.T) {
|
||||
code, message, failed := providerPayloadBusinessFailure(map[string]any{
|
||||
"output": map[string]any{
|
||||
"code": "InvalidParameter",
|
||||
"message": "Input should be '1080P', '720P' or '480P': parameters.resolution",
|
||||
"task_id": "e0d8c86d-4939-4f2e-93f7-e2cd10a07d58",
|
||||
"task_status": "FAILED",
|
||||
},
|
||||
"request_id": "c3c98e67-830d-9f1d-8a62-fff019ffa522",
|
||||
})
|
||||
if !failed || code != "InvalidParameter" {
|
||||
t.Fatalf("nested output failure = (%q, %q, %v)", code, message, failed)
|
||||
}
|
||||
if !strings.Contains(message, "parameters.resolution") {
|
||||
t.Fatalf("unexpected message: %q", message)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProviderPayloadBusinessFailureIgnoresPendingOutput(t *testing.T) {
|
||||
if code, message, failed := providerPayloadBusinessFailure(map[string]any{
|
||||
"output": map[string]any{"task_id": "task-1", "task_status": "PENDING"},
|
||||
"request_id": "req-1",
|
||||
}); failed {
|
||||
t.Fatalf("pending output marked failed: (%q, %q)", code, message)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user