Skip to content

Commit

Permalink
CLI-1429: Allow production environments for log:tail and drush comman…
Browse files Browse the repository at this point in the history
…ds (#1828)

* CLI-1429: Allow production environments for log:tail and drush commands

* kill mutant

* kill mutant
  • Loading branch information
danepowell authored Nov 14, 2024
1 parent b136a7a commit b12cc94
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Command/App/LogTailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
$environment = $this->determineEnvironment($input, $output);
$environment = $this->determineEnvironment($input, $output, true);
$acquiaCloudClient = $this->cloudApiClientService->getClient();
$logs = $this->promptChooseLogs();
$logTypes = array_map(static function (mixed $log) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Remote/DrushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): ?int
{
$environment = $this->determineEnvironment($input, $output);
$environment = $this->determineEnvironment($input, $output, true);
$alias = self::getEnvironmentAlias($environment);
$acliArguments = $input->getArguments();
$drushArguments = (array) $acliArguments['drush_command'];
Expand Down
32 changes: 30 additions & 2 deletions tests/phpunit/src/Commands/App/LogTailCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,34 @@ public function testLogTailCommandWithEnvArg(): void
$this->assertStringContainsString('Drupal request', $output);
}

public function testLogTailProd(): void
{
$applications = $this->mockRequest('getApplications');
$application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
$this->mockRequest('getApplicationEnvironments', $application->uuid);
$this->mockLogStreamRequest('15-a47ac10b-58cc-4372-a567-0e02b2c3d470');
$this->executeCommand(
[],
[
// Would you like Acquia CLI to search for a Cloud application that matches your local git config?
'n',
// Select the application.
0,
// Would you like to link the project at ... ?
'y',
// Select environment.
1,
// Select log.
0,
]
);

// Assert.
$output = $this->getDisplay();
$this->assertStringContainsString('Apache request', $output);
$this->assertStringContainsString('Drupal request', $output);
}

public function testLogTailNode(): void
{
$applications = $this->mockRequest('getApplications');
Expand All @@ -129,7 +157,7 @@ public function testLogTailNode(): void
]);
}

private function mockLogStreamRequest(): void
private function mockLogStreamRequest(string $environment = '24-a47ac10b-58cc-4372-a567-0e02b2c3d470'): void
{
$response = self::getMockResponseFromSpec(
'/environments/{environmentId}/logstream',
Expand All @@ -138,7 +166,7 @@ private function mockLogStreamRequest(): void
);
$this->clientProphecy->request(
'get',
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/logstream'
'/environments/' . $environment . '/logstream'
)
->willReturn($response)
->shouldBeCalled();
Expand Down

0 comments on commit b12cc94

Please sign in to comment.