Skip to content

Commit a30a120

Browse files
authored
Merge pull request #346 from keboola/pepa_SOX-406_publicApiFields
SOX-406 [public api] Add new job fields
2 parents 1bcc5e9 + 5153d28 commit a30a120

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

src/JobFactory/FullJobDefinition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ protected function getRootDefinition(TreeBuilder $treeBuilder): ArrayNodeDefinit
219219
->ifTrue(fn($v) => count(array_filter($v ?? [], fn($i) => $i === '')) > 0)
220220
->thenInvalid('item cannot be empty string')
221221
->end()
222+
->validate()
223+
->ifTrue(fn($v) => $v !== null && count($v) !== count(array_unique($v)))
224+
->thenInvalid('items must be unique')
225+
->end()
222226
->end()
223227
->scalarNode('previousJobId')
224228
->validate()

src/JobFactory/NewJobDefinition.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ protected function getRootDefinition(TreeBuilder $treeBuilder): ArrayNodeDefinit
112112
->ifTrue(fn($v) => count(array_filter($v ?? [], fn($i) => $i === '')) > 0)
113113
->thenInvalid('item cannot be empty string')
114114
->end()
115+
->validate()
116+
->ifTrue(fn($v) => $v !== null && count($v) !== count(array_unique($v)))
117+
->thenInvalid('items must be unique')
118+
->end()
115119
->end()
116120
->scalarNode('previousJobId')
117121
->validate()

tests/JobFactory/FullJobDefinitionTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,22 @@ public function invalidJobProvider(): array
521521
],
522522
'/Invalid configuration for path "job.onlyOrchestrationTaskIds": item cannot be empty string/',
523523
],
524+
'onlyOrchestrationTaskIds with duplicated item' => [
525+
[
526+
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),
527+
'id' => '12345',
528+
'runId' => '12345',
529+
'tokenId' => '1234',
530+
'projectId' => '123',
531+
'status' => 'created',
532+
'desiredStatus' => 'processing',
533+
'configId' => '123',
534+
'componentId' => 'keboola.test',
535+
'mode' => 'run',
536+
'onlyOrchestrationTaskIds' => ['11', '22', '11'],
537+
],
538+
'/Invalid configuration for path "job.onlyOrchestrationTaskIds": items must be unique/',
539+
],
524540
'previousJobId not string' => [
525541
[
526542
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),

tests/JobFactory/NewJobDefinitionTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ public function invalidJobProvider(): array
224224
],
225225
'/Invalid configuration for path "job.onlyOrchestrationTaskIds": item cannot be empty string/',
226226
],
227+
'onlyOrchestrationTaskIds with duplicated item' => [
228+
[
229+
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),
230+
'configId' => '123',
231+
'componentId' => 'keboola.test',
232+
'result' => [],
233+
'onlyOrchestrationTaskIds' => ['11', '22', '11'],
234+
],
235+
'/Invalid configuration for path "job.onlyOrchestrationTaskIds": items must be unique/',
236+
],
227237
'previousJobId not string' => [
228238
[
229239
'#tokenString' => getenv('TEST_STORAGE_API_TOKEN'),

0 commit comments

Comments
 (0)