Skip to content

Commit

Permalink
fix: Two methods in DataGovUkExport did not call new parent uploadToS…
Browse files Browse the repository at this point in the history
…3 method. (#378)
  • Loading branch information
fibble authored Oct 10, 2024
1 parent d0f2169 commit d4b8b9f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ private function processPsvOperatorList()
['id' => $document->getId('document')],
$document->getId('document')
);

$tempFilePath = tempnam(sys_get_temp_dir(), 'psv_operator_list_');
file_put_contents($tempFilePath, $csvContent);
$this->uploadToS3($tempFilePath);
unlink($tempFilePath);

$email = $this->handleSideEffect($emailQueue);
$this->result->merge($email);

Expand Down Expand Up @@ -135,6 +141,8 @@ private function processInternationalGoodsList()
$document->getId('document')
);

$this->uploadToS3($csvContent);

$email = $this->handleSideEffect($emailQueue);
$this->result->merge($email);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,22 @@ public function testInternationalGoods()
]
);

$this->mockS3client->shouldAllowMockingMethod('putObject');
$this->mockS3client->shouldReceive('putObject')
->once()
->andReturn([]);

$actual = $this->sut->handleCommand($cmd);

$date = new DateTime('now');
$expectedFile = $this->tmpPath . '/' . $fileName . '_' .

$expectedFileName = $fileName . '_' .
$date->format(DataGovUkExport::FILE_DATETIME_FORMAT) . '.csv';
$expectedFilePath = $this->tmpPath . '/' . $expectedFileName;

$expectMsg =
'Fetching data for international goods list' .
'Creating CSV file: ' . $expectedFile;
'Creating CSV file: ' . $expectedFilePath . 'Uploaded file to S3: '.$expectedFileName;

$this->assertEquals(
$expectMsg,
Expand Down Expand Up @@ -294,16 +301,20 @@ public function testPsvOperatorListOk()
]
);

$this->mockS3client->shouldAllowMockingMethod('putObject');
$this->mockS3client->shouldReceive('putObject')
->once()
->andReturn([]);

$actual = $this->sut->handleCommand($cmd);

$expectMsg =
'Fetching data from DB for PSV Operators' .
'create csv file content';
'create csv file contentUploaded file to S3: psv_operator_list_';

static::assertEquals(
$expectMsg,
implode('', $actual->toArray()['messages'])
);
$actualMsg = implode('', $actual->toArray()['messages']);

static::assertStringStartsWith($expectMsg, $actualMsg);
}

public function testOperatorLicenceOk()
Expand Down

0 comments on commit d4b8b9f

Please sign in to comment.