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

GL-2753 : CS Wizard updated node version select values #1767

Merged
merged 5 commits into from
Jul 11, 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
6 changes: 3 additions & 3 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
break;
case "Node_project":
$nodeVersions = [
'NODE_version_18.17.1' => "18.17.1",
'NODE_version_20.5.1' => "20.5.1",
'NODE_version_18' => "18",
'NODE_version_20' => "20",
];
$project = $this->io->choice('Select a NODE version', array_values($nodeVersions), "18.17.1");
$project = $this->io->choice('Select a NODE version', array_values($nodeVersions), "20");
$project = array_search($project, $nodeVersions, true);
$nodeVersion = $nodeVersions[$project];
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function providerTestCommand(): array
[$this->getMockedGitLabProject($this->gitLabProjectId)],
// Inputs.
[
0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test cases are all providing invalid input, and since there are practically no assertions they were overlooked.

This fixes the inputs to at least be valid, but I'm not sure if the test cases are actually testing what they're supposed to...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I failed to understand, even when the inputs were wrong the output should not have contained the success messages which was asserted in the last.
I will probably keep this one to be worked upon in future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think this method only returns one line. Ideally you'd be checking the entire output:

        $output_strings = $this->getOutputStrings();

0,
// Do you want to continue?
'y',
// Would you like to perform a one time push of code from Acquia Cloud to Code Studio now? (yes/no) [yes]:
Expand All @@ -84,6 +86,9 @@ public function providerTestCommand(): array
],
// Inputs.
[
0,
0,
'n',
// Found multiple projects that could match the Sample application 1 application. Choose which one to configure.
'0',
// Do you want to continue?
Expand All @@ -102,6 +107,8 @@ public function providerTestCommand(): array
[],
// Inputs.
[
0,
0,
// 'Would you like to create a new Code Studio project?
'y',
// Select a project type Drupal_project.
Expand All @@ -124,8 +131,6 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Select a project type Drupal_project.
'0',
// Select PHP version 8.2.
Expand All @@ -146,11 +151,9 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Select a project type Node_project.
'1',
// Select NODE version 18.17.1.
// Select NODE version 18.
'0',
// Do you want to continue?
'y',
Expand All @@ -168,11 +171,9 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Select a project type Node_project.
'1',
// Select NODE version 20.5.1.
// Select NODE version 20.
'1',
// Do you want to continue?
'y',
Expand All @@ -190,8 +191,10 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'n',
0,
0,
'y',
'y',
// Choose project.
'0',
// Do you want to continue?
Expand All @@ -208,8 +211,6 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Enter Cloud Key.
$this->key,
// Enter Cloud secret,.
Expand All @@ -229,15 +230,13 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Enter Cloud Key.
$this->key,
// Enter Cloud secret,.
$this->secret,
// Select a project type Node_project.
'1',
// Select NODE version 18.17.1.
// Select NODE version 18.
'0',
// Do you want to continue?
'y',
Expand All @@ -250,8 +249,6 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Enter Cloud Key.
$this->key,
// Enter Cloud secret,.
Expand All @@ -271,15 +268,13 @@ public function providerTestCommand(): array
[],
// Inputs.
[
// 'Would you like to create a new Code Studio project?
'y',
// Enter Cloud Key.
$this->key,
// Enter Cloud secret,.
$this->secret,
// Select a project type Node_project.
'1',
// Select NODE version 20.5.1.
// Select NODE version 20.
'1',
// Do you want to continue?
'y',
Expand Down Expand Up @@ -332,7 +327,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a
)->shouldBeCalled();
$this->mockGitLabVariables($this->gitLabProjectId, $projects);

if ($inputs[0] === 'y' && ($inputs[1] === '1' || (array_key_exists(3, $inputs) && $inputs[3] === '1'))) {
if (($inputs[0] === '1' || (array_key_exists(2, $inputs) && $inputs[2] === '1'))) {
$parameters = [
'ci_config_path' => 'gitlab-ci/Auto-DevOps.acquia.gitlab-ci.yml@acquia/node-template',
];
Expand Down Expand Up @@ -387,6 +382,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a
foreach ($output_strings as $output_string) {
self::assertStringContainsString($output_string, $output);
}
self::assertStringNotContainsString('[ERROR]', $output);

// Assertions.
$this->assertEquals(0, $this->getStatusCode());
Expand Down
Loading