Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading