|
5 | 5 | namespace Keboola\JobQueueInternalClient\Tests; |
6 | 6 |
|
7 | 7 | use DateTimeImmutable; |
8 | | -use Keboola\JobQueueInternalClient\Client; |
9 | 8 | use Keboola\JobQueueInternalClient\Exception\ClientException; |
10 | 9 | use Keboola\JobQueueInternalClient\Exception\StateTargetEqualsCurrentException; |
11 | 10 | use Keboola\JobQueueInternalClient\JobFactory\Job; |
12 | 11 | use Keboola\JobQueueInternalClient\JobFactory\JobInterface; |
| 12 | +use Keboola\JobQueueInternalClient\JobFactory\ObjectEncryptor\JobObjectEncryptor; |
13 | 13 | use Keboola\JobQueueInternalClient\JobListOptions; |
14 | 14 | use Keboola\JobQueueInternalClient\JobPatchData; |
15 | 15 | use Keboola\JobQueueInternalClient\JobsSortOptions; |
|
19 | 19 | use Keboola\StorageApi\Components; |
20 | 20 | use Keboola\StorageApi\DevBranches; |
21 | 21 | use Keboola\StorageApi\Options\Components\Configuration; |
22 | | -use Psr\Log\NullLogger; |
| 22 | +use Keboola\StorageApiBranch\Factory\StorageClientPlainFactory; |
23 | 23 |
|
24 | 24 | class ClientFunctionalTest extends BaseClientFunctionalTest |
25 | 25 | { |
@@ -537,6 +537,40 @@ public function testListJobsByComponent(): void |
537 | 537 | self::assertCount(2, $response); |
538 | 538 | } |
539 | 539 |
|
| 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 | + |
540 | 574 | public function testListJobsSort(): void |
541 | 575 | { |
542 | 576 | $newJobFactory = $this->getNewJobFactory(); |
|
0 commit comments