Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jun 3, 2024
1 parent 9d1079b commit 468ac78
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Client/GRPC/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function withTimeout($timeout, string $format = DateInterval::FORMAT_SECO

$ctx = clone $this;
$ctx->timeout = $internal;
$ctx->deadline =null;
$ctx->deadline = null;

return $ctx;
}
Expand Down
25 changes: 24 additions & 1 deletion tests/Unit/Client/GRPC/BaseClientTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Temporal\Client\GRPC\ContextInterface;
use Temporal\Client\GRPC\ServiceClient;
use Temporal\Client\GRPC\StatusCode;
use Temporal\Common\RetryOptions;
use Temporal\Exception\Client\ServiceClientException;
use Temporal\Exception\Client\TimeoutException;
use Temporal\Internal\Interceptor\Pipeline;
Expand Down Expand Up @@ -87,6 +86,30 @@ public function testWithContext(): void
$this->assertNotSame($client, $client2);
}

public function testWithTimeoutDynamicDeadline(): void
{
$client = $this->createClientMock();
$context = $client->getContext()->withTimeout(1.234);

$this->assertNotSame($context->getDeadline(), $context->getDeadline());
}

public function testContextGetDeadlineWithoutDeadline(): void
{
$client = $this->createClientMock();
$context = $client->getContext();

$this->assertNull($context->getDeadline());
}

public function testContextGetDeadlineWithStaticDeadline(): void
{
$client = $this->createClientMock();
$context = $client->getContext()->withDeadline(new DateTimeImmutable('+1 second'));

$this->assertSame($context->getDeadline(), $context->getDeadline());
}

public function testWithAuthKey(): void
{
$client = $this->createClientMock();
Expand Down

0 comments on commit 468ac78

Please sign in to comment.