mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 08:14:55 +08:00
@@ -336,6 +336,45 @@ func TestScheduleRunSendsScopeAndMaxRuns(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTranslationTaskUpdateSendsWorkerParams(t *testing.T) {
|
||||
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
|
||||
if req.Method != "translation.task.update" {
|
||||
t.Fatalf("method = %s", req.Method)
|
||||
}
|
||||
var params TranslationTaskUpdateParams
|
||||
if err := json.Unmarshal(req.Params, ¶ms); err != nil {
|
||||
t.Fatalf("decode params: %v", err)
|
||||
}
|
||||
if params.TaskID != "textunit/v-current/Scenario" ||
|
||||
params.Status != "failed" ||
|
||||
params.FailureReason != "provider rejected payload" ||
|
||||
params.ProviderRunID != "provider-run-1" {
|
||||
t.Fatalf("params = %#v", params)
|
||||
}
|
||||
return testResponse{
|
||||
Result: testEnvelope{
|
||||
OK: true,
|
||||
Status: "ok",
|
||||
RequestID: "req-test-translation-update",
|
||||
Data: map[string]any{"task_status": "failed"},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
raw, err := client.TranslationTaskUpdate(context.Background(), TranslationTaskUpdateParams{
|
||||
TaskID: "textunit/v-current/Scenario",
|
||||
Status: "failed",
|
||||
FailureReason: "provider rejected payload",
|
||||
ProviderRunID: "provider-run-1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("TranslationTaskUpdate error: %v", err)
|
||||
}
|
||||
if !json.Valid(raw) {
|
||||
t.Fatalf("invalid raw JSON: %s", string(raw))
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplicationErrorReturnsAPIError(t *testing.T) {
|
||||
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
|
||||
if req.Method != "task.status" {
|
||||
|
||||
Reference in New Issue
Block a user