Skip to content

Commit ba35729

Browse files
committed
tests (internal-api-client): listing jobs with branchType = null
1 parent 8c0c125 commit ba35729

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

tests/ClientFunctionalTest.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace Keboola\JobQueueInternalClient\Tests;
66

77
use DateTimeImmutable;
8-
use Keboola\JobQueueInternalClient\Client;
98
use Keboola\JobQueueInternalClient\Exception\ClientException;
109
use Keboola\JobQueueInternalClient\Exception\StateTargetEqualsCurrentException;
1110
use Keboola\JobQueueInternalClient\JobFactory\Job;
1211
use Keboola\JobQueueInternalClient\JobFactory\JobInterface;
12+
use Keboola\JobQueueInternalClient\JobFactory\ObjectEncryptor\JobObjectEncryptor;
1313
use Keboola\JobQueueInternalClient\JobListOptions;
1414
use Keboola\JobQueueInternalClient\JobPatchData;
1515
use Keboola\JobQueueInternalClient\JobsSortOptions;
@@ -19,7 +19,7 @@
1919
use Keboola\StorageApi\Components;
2020
use Keboola\StorageApi\DevBranches;
2121
use Keboola\StorageApi\Options\Components\Configuration;
22-
use Psr\Log\NullLogger;
22+
use Keboola\StorageApiBranch\Factory\StorageClientPlainFactory;
2323

2424
class ClientFunctionalTest extends BaseClientFunctionalTest
2525
{
@@ -537,6 +537,40 @@ public function testListJobsByComponent(): void
537537
self::assertCount(2, $response);
538538
}
539539

540+
public function testListJobsWithBranchTypeNull(): void
541+
{
542+
// jobs before branchType has branchType = null
543+
$newJobFactory = $this->getNewJobFactory();
544+
$client = $this->getClient();
545+
546+
$job = $newJobFactory->createNewJob([
547+
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),
548+
'configId' => self::$configId1,
549+
'componentId' => self::COMPONENT_ID_1,
550+
'mode' => 'run',
551+
]);
552+
$jobData = array_merge($job->jsonSerialize(), ['branchType' => null]);
553+
554+
$objectEncryptor = $this->createMock(JobObjectEncryptor::class);
555+
$storageClientFactory = $this->createMock(StorageClientPlainFactory::class);
556+
557+
$jobWithBranchTypeNull = new Job($objectEncryptor, $storageClientFactory, $jobData);
558+
559+
$createdJob = $client->createJob($jobWithBranchTypeNull);
560+
561+
// list one component
562+
$response = $client->listJobs(
563+
(new JobListOptions())
564+
->setStatuses([JobInterface::STATUS_CREATED]),
565+
true
566+
);
567+
self::assertCount(1, $response);
568+
/** @var Job $listedJob */
569+
$listedJob = $response[0];
570+
self::assertEquals($createdJob->jsonSerialize(), $listedJob->jsonSerialize());
571+
self::assertNull($listedJob->getBranchType());
572+
}
573+
540574
public function testListJobsSort(): void
541575
{
542576
$newJobFactory = $this->getNewJobFactory();

0 commit comments

Comments
 (0)