Skip to content

Commit 9a2cfb0

Browse files
Use explicit Avro payloads in v2 control-plane tests
1 parent cfd8e95 commit 9a2cfb0

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

tests/Feature/V2/V2WebhookPollAndControlPlaneTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Facades\Queue;
88
use Tests\Fixtures\V2\TestGreetingWorkflow;
99
use Tests\TestCase;
10+
use Workflow\Serializers\CodecRegistry;
1011
use Workflow\Serializers\Serializer;
1112
use Workflow\V2\Enums\ActivityStatus;
1213
use Workflow\V2\Enums\RunStatus;
@@ -191,7 +192,7 @@ public function testControlPlaneStartCreatesWorkflow(): void
191192
$response = $this->postJson('/webhooks/control-plane/start', [
192193
'workflow_type' => 'test-greeting-workflow',
193194
'instance_id' => 'cp-start-1',
194-
'arguments' => Serializer::serialize(['Taylor']),
195+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
195196
'connection' => 'redis',
196197
'queue' => 'default',
197198
]);
@@ -210,13 +211,13 @@ public function testControlPlaneStartRejectsDuplicate(): void
210211
$this->postJson('/webhooks/control-plane/start', [
211212
'workflow_type' => 'test-greeting-workflow',
212213
'instance_id' => 'cp-dup-1',
213-
'arguments' => Serializer::serialize(['Taylor']),
214+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
214215
])->assertStatus(202);
215216

216217
$response = $this->postJson('/webhooks/control-plane/start', [
217218
'workflow_type' => 'test-greeting-workflow',
218219
'instance_id' => 'cp-dup-1',
219-
'arguments' => Serializer::serialize(['Taylor']),
220+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
220221
]);
221222

222223
$response->assertStatus(409);
@@ -229,13 +230,13 @@ public function testControlPlaneStartReturnsExistingActive(): void
229230
$this->postJson('/webhooks/control-plane/start', [
230231
'workflow_type' => 'test-greeting-workflow',
231232
'instance_id' => 'cp-reuse-1',
232-
'arguments' => Serializer::serialize(['Taylor']),
233+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
233234
])->assertStatus(202);
234235

235236
$response = $this->postJson('/webhooks/control-plane/start', [
236237
'workflow_type' => 'test-greeting-workflow',
237238
'instance_id' => 'cp-reuse-1',
238-
'arguments' => Serializer::serialize(['Taylor']),
239+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
239240
'duplicate_start_policy' => 'return_existing_active',
240241
]);
241242

@@ -268,7 +269,7 @@ public function testControlPlaneStartWithVisibilityMetadata(): void
268269
$response = $this->postJson('/webhooks/control-plane/start', [
269270
'workflow_type' => 'test-greeting-workflow',
270271
'instance_id' => 'cp-vis-1',
271-
'arguments' => Serializer::serialize(['Taylor']),
272+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
272273
'business_key' => 'order-123',
273274
'labels' => [
274275
'tenant' => 'acme',
@@ -289,7 +290,7 @@ public function testControlPlaneStartWithAutoGeneratedInstanceId(): void
289290
{
290291
$response = $this->postJson('/webhooks/control-plane/start', [
291292
'workflow_type' => 'test-greeting-workflow',
292-
'arguments' => Serializer::serialize(['Taylor']),
293+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
293294
]);
294295

295296
$response->assertStatus(202);
@@ -319,7 +320,7 @@ private function createWaitingRun(): WorkflowRun
319320
'workflow_class' => TestGreetingWorkflow::class,
320321
'workflow_type' => 'test-greeting-workflow',
321322
'status' => RunStatus::Waiting->value,
322-
'arguments' => Serializer::serialize(['Taylor']),
323+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
323324
'connection' => 'redis',
324325
'queue' => 'default',
325326
'compatibility' => 'build-a',
@@ -350,7 +351,7 @@ private function createActivityTask(): array
350351
'activity_type' => 'test-greeting-activity',
351352
'sequence' => 1,
352353
'status' => ActivityStatus::Pending->value,
353-
'arguments' => Serializer::serialize(['Taylor']),
354+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
354355
'connection' => 'redis',
355356
'queue' => 'default',
356357
'attempt_count' => 0,

tests/Feature/V2/V2WorkflowControlPlaneTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Tests\Fixtures\V2\TestSignalWorkflow;
1313
use Tests\Fixtures\V2\TestUpdateWorkflow;
1414
use Tests\TestCase;
15+
use Workflow\Serializers\CodecRegistry;
1516
use Workflow\Serializers\Serializer;
1617
use Workflow\V2\CommandContext;
1718
use Workflow\V2\Contracts\HistoryProjectionRole;
@@ -63,7 +64,7 @@ public function testStartWithLocallyResolvableClass(): void
6364
]);
6465

6566
$result = $this->controlPlane->start('test-greeting-workflow', 'ctrl-plane-test-1', [
66-
'arguments' => Serializer::serialize(['Taylor']),
67+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
6768
'connection' => 'redis',
6869
'queue' => 'default',
6970
]);
@@ -100,7 +101,7 @@ public function testStartWithLocallyResolvableClass(): void
100101
public function testStartWithTypeKeyOnly(): void
101102
{
102103
$result = $this->controlPlane->start('remote-workflow-type', 'ctrl-plane-test-2', [
103-
'arguments' => Serializer::serialize(['arg1']),
104+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['arg1']),
104105
'connection' => 'redis',
105106
'queue' => 'remote-workers',
106107
]);
@@ -369,7 +370,7 @@ public function testSignalWithDurableContract(): void
369370
]);
370371

371372
$this->controlPlane->start('test-greeting-workflow', 'ctrl-plane-signal-1', [
372-
'arguments' => Serializer::serialize(['Taylor']),
373+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
373374
'connection' => 'redis',
374375
'queue' => 'default',
375376
]);
@@ -403,7 +404,7 @@ public function testStartWithExplicitRoutingOverridesClassDefaults(): void
403404
]);
404405

405406
$result = $this->controlPlane->start('test-greeting-workflow', 'ctrl-plane-routing-1', [
406-
'arguments' => Serializer::serialize(['Taylor']),
407+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
407408
'connection' => 'redis',
408409
'queue' => 'custom-queue',
409410
]);
@@ -450,7 +451,7 @@ public function testStartResolvesDottedDurableTypeKey(): void
450451
]);
451452

452453
$result = $this->controlPlane->start('tests.external-greeting-workflow', 'ctrl-plane-dotted-1', [
453-
'arguments' => Serializer::serialize(['Taylor']),
454+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
454455
'connection' => 'redis',
455456
'queue' => 'default',
456457
]);
@@ -503,7 +504,7 @@ public function testDescribeActiveWorkflow(): void
503504
]);
504505

505506
$start = $this->controlPlane->start('test-greeting-workflow', 'ctrl-plane-desc-1', [
506-
'arguments' => Serializer::serialize(['Taylor']),
507+
'arguments' => Serializer::serializeWithCodec(CodecRegistry::defaultCodec(), ['Taylor']),
507508
'connection' => 'redis',
508509
'queue' => 'default',
509510
'business_key' => 'order-100',

0 commit comments

Comments
 (0)