Skip to content

Commit

Permalink
Adds feature specs to connection:info
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbarry authored Sep 22, 2016
2 parents 9cce8ec + b386691 commit 8a06081
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 31 deletions.
80 changes: 77 additions & 3 deletions tests/active_features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ public function aPaymentInstrumentWithUuid($instrument_uuid)

/**
* Ensures a site of the given name exists
*
* @Given /^a site named "([^"]*)"$/
* @Given /^a site named: (.*)$/
*
* @param [string] $site Name of site to ensure exists
* @return [boolean] Always true, else errs
* @param string $site Name of site to ensure exists
* @return boolean Always true, else errs
* @throws \Exception
*/
public function aSiteNamed($site)
{
Expand Down Expand Up @@ -368,7 +371,7 @@ public function iGetInfoForTheEnvironmentOf($env, $site)
*/
public function iGetInfoForTheSite($site)
{
$return = json_decode($this->iRun("terminus site:info $site --format=json"));
$return = $this->iRun("terminus site:info $site");
return $return;
}

Expand Down Expand Up @@ -671,6 +674,77 @@ public function iShouldGet($string)
return $i_have_this;
}

/**
* Checks the output for a table with the given headers
*
* @Then /^I should see a table with the headers$/
* @Then /^I should see a table with the headers: ([^"]*)$/
* @Then /^I should see a table with the headers: "([^"]*)"$/
*
* @param string $headers Comma separated row values to match
* @return boolean true if $headers exists in output
*
* @throws \Exception
*/
public function shouldSeeATableWithHeaders($headers)
{
$table_headers = explode(',', $headers);
foreach ($table_headers as $column) {
if (!$this->checkResult(trim((string)$column), $this->output)) {
throw new \Exception("Expected table headers to include: '{$column}' in table:\n{$this->output}\n");
}
}

return true;
}

/**
* Checks the output for a table with the given row values
*
* @Then /^I should see a table with rows like:$/
* @Then /^I should see a table with rows like"([^"]*)"$/
* @Then /^I should see a table with rows like: "([^"]*)"$/
*
* @param $rows string newline separated row values to match
* @return boolean true if all of the rows are present in the output
* @throws \Exception
*/
public function shouldSeeATableWithRows($rows)
{
$lines = explode("\n", $rows);
foreach ($lines as $line) {
if (!$this->checkResult(trim((string)$line), $this->output)) {
throw new \Exception("Expected the row '{$line}' in table:\n{$this->output}\n");
}
}

return true;
}

/**
* Checks the output for a type of message. Message to match is optional.
*
* @Then /^I should see a[n]? (notice|warning|error) message$/
* @Then /^I should see a[n]? (notice|warning|error) message: (.*)$/
*
* @param $type string One of the standard logging levels
* @param $message string Optional message to match in the output
* @return bool True if message is the correct type and exists in output if given
* @throws \Exception
*/
public function shouldSeeATypeOfMessage($type, $message = null)
{
$type_marker = "[$type]";
if (strpos($this->output, $type_marker) === false) {
throw new \Exception("Expected $type_marker in message: $this->output");
}

if (!empty($message) and strpos($this->output, $message) === false) {
throw new \Exception("Expected '$message' in message: $this->output");
}
return true;
}

/**
* @Then /^I should get a valid UUID/
* Checks the output for a valid UUID
Expand Down
58 changes: 58 additions & 0 deletions tests/active_features/connection-info.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@environment @connection
Feature: Environment Connection Info Command
In order to see connection parameters for remotely accessing the environment of a given site
As a Terminus user
I want a command to view the current connection parameters.

Background: I am authenticated and have a site named [[test_site_name]]
Given I am authenticated
And a site named: [[test_site_name]]

@vcr site_connection-info
Scenario: Show all connection info for a site's environment
When I run "terminus connection:info [[test_site_name]].dev"
Then I should see a table with the headers: Parameter, Connection Info
And I should see a table with rows like:
"""
sftp_command
sftp_host
sftp_password
sftp_url
sftp_username
git_username
git_host
git_port
git_url
git_command
mysql_host
mysql_username
mysql_password
mysql_port
mysql_database
mysql_url
mysql_command
redis_password
redis_host
redis_port
redis_url
redis_command
"""

@vcr site_connection-info
Scenario: Show only a specific connection info parameter for a site's environment
When I run "terminus connection:info [[test_site_name]].dev git_command"
Then I should see a table with the headers: Parameter, Connection Info
And I should see a table with rows like:
"""
git_command
"""

@vcr site_connection-info
Scenario: Specify connection info table headers
When I run "terminus connection:info [[test_site_name]].dev --fields=env,param,value"
Then I should see a table with the headers: Environment, Parameter, Connection Info

@vcr site_connection-info
Scenario: Show only a specific connection info parameter for a site's environment
When I run "terminus connection:info [[test_site_name]]"
Then I should see an error message: The environment argument must be given as <site_name>.<environment>
28 changes: 0 additions & 28 deletions tests/newfeatures/connection-info.feature

This file was deleted.

0 comments on commit 8a06081

Please sign in to comment.