mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 10:04:55 +08:00
@@ -561,6 +561,75 @@ func TestTranslationProofreadUsesRustMethod(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizedPublishSendsWorkerSourceAndReleaseOptions(t *testing.T) {
|
||||
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
|
||||
if req.Method != "localized.publish" {
|
||||
t.Fatalf("method = %s", req.Method)
|
||||
}
|
||||
var params LocalizedPublishParams
|
||||
if err := json.Unmarshal(req.Params, ¶ms); err != nil {
|
||||
t.Fatalf("decode params: %v", err)
|
||||
}
|
||||
if !params.FromWorker || params.TranslationFile != "" ||
|
||||
params.LocalizedReleaseID != "localized-1" || !params.Force {
|
||||
t.Fatalf("params = %#v", params)
|
||||
}
|
||||
return testResponse{
|
||||
Result: testEnvelope{
|
||||
OK: true,
|
||||
Status: "ok",
|
||||
RequestID: "req-test-localized-publish",
|
||||
Data: map[string]any{"status": "published"},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
raw, err := client.LocalizedPublish(context.Background(), LocalizedPublishParams{
|
||||
FromWorker: true,
|
||||
LocalizedReleaseID: "localized-1",
|
||||
Force: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("LocalizedPublish error: %v", err)
|
||||
}
|
||||
if !json.Valid(raw) {
|
||||
t.Fatalf("invalid raw JSON: %s", string(raw))
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocalizedRollbackSendsExpectedRelease(t *testing.T) {
|
||||
client := newTestClient(t, func(t *testing.T, req testRequest) testResponse {
|
||||
if req.Method != "localized.rollback" {
|
||||
t.Fatalf("method = %s", req.Method)
|
||||
}
|
||||
var params LocalizedRollbackParams
|
||||
if err := json.Unmarshal(req.Params, ¶ms); err != nil {
|
||||
t.Fatalf("decode params: %v", err)
|
||||
}
|
||||
if params.LocalizedReleaseID != "localized-1" {
|
||||
t.Fatalf("params = %#v", params)
|
||||
}
|
||||
return testResponse{
|
||||
Result: testEnvelope{
|
||||
OK: true,
|
||||
Status: "ok",
|
||||
RequestID: "req-test-localized-rollback",
|
||||
Data: map[string]any{"status": "rolled_back"},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
raw, err := client.LocalizedRollback(context.Background(), LocalizedRollbackParams{
|
||||
LocalizedReleaseID: "localized-1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("LocalizedRollback 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