Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Added cucumber tests for rhc env
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianofranz committed Sep 3, 2013
1 parent 7656238 commit 51e1a17
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
29 changes: 29 additions & 0 deletions features/env.feature
@@ -0,0 +1,29 @@
@env_var @domain_required
Feature: Environment Variables Operations

@init
Scenario: Application Creation
When a php application is created
Then the application should be accessible

Scenario: Environment variable is set
When a new environment variable "FOO" is set as "BAR"
And the existing environment variables are listed
Then the output environment variables include "FOO=BAR"

Scenario: Environment variables are set
When a new environment variable "FOO" is set as "BAR"
And a new environment variable "FOO2" is set as "BAR2"
And the existing environment variables are listed
Then the output environment variables include "FOO=BAR"
And the output environment variables include "FOO2=BAR2"

Scenario: Environment variable is unset
When a new environment variable "FOO" is set as "BAR"
And the existing environment variables are listed
Then the output environment variables include "FOO=BAR"
When an existing environment variable with name "FOO" is unset
Then the output environment variables do not include "FOO=BAR"

# Scenario: Create app with environment variable
# Scenario: add cartridge with environment variable
1 change: 1 addition & 0 deletions features/lib/rhc_helper.rb
Expand Up @@ -18,3 +18,4 @@ module RHCHelper
require 'rhc_helper/app'
require 'rhc_helper/domain'
require 'rhc_helper/sshkey'
require 'rhc_helper/env'
28 changes: 25 additions & 3 deletions features/lib/rhc_helper/commandify.rb
Expand Up @@ -93,6 +93,8 @@ def get_args(cmd, arg0=nil, debug=true)
# in RHCHelper::Sshkey, we pass *args to method_missing here, so that
# we _know_ that arg0 is an Array.
args << arg0.first if arg0.first
when /env/
args << arg0.first if arg0.first
end

args.rstrip.gsub(/([\\\$])/, "\\\\\\1")
Expand Down Expand Up @@ -187,7 +189,7 @@ def domain_show_callback(exitcode, stdout, stderr, arg)
def domain_create_callback(exitcode, stdout, stderr, arg)
@exitcode = exitcode
end

def domain_update_callback(exitcode, stdout, stderr, arg)
@exitcode = exitcode
end
Expand All @@ -200,7 +202,7 @@ def sshkey_callback(exitcode, stdout, stderr, arg)
@sshkey_output = stdout
@exitcode = exitcode
end

def sshkey_add_callback(exitcode, stdout, stderr, arg)
@sshkey_output = stdout
@exitcode = exitcode
Expand All @@ -215,7 +217,7 @@ def sshkey_show_callback(exitcode, stdout, stderr, arg)
@sshkey_output = stdout
@exitcode = exitcode
end

def sshkey_update_callback(exitcode, stdout, stderr, arg)
@sshkey_output = stdout
@exitcode = exitcode
Expand All @@ -226,4 +228,24 @@ def sshkey_delete_callback(exitcode, stdout, stderr, arg)
@exitcode = exitcode
end

def env_list_callback(exitcode, stdout, stderr, arg)
@env_output = stdout
@exitcode = exitcode
end

def env_show_callback(exitcode, stdout, stderr, arg)
@env_output = stdout
@exitcode = exitcode
end

def env_set_callback(exitcode, stdout, stderr, arg)
@env_output = stdout
@exitcode = exitcode
end

def env_unset_callback(exitcode, stdout, stderr, arg)
@env_output = stdout
@exitcode = exitcode
end

end
28 changes: 28 additions & 0 deletions features/step_definitions/env_steps.rb
@@ -1 +1,29 @@
include RHCHelper

When /^'rhc env (\S+)( .*?)?'(?: command)? is run$/ do |subcommand, rest|
if subcommand =~ /^(list|show|set|unset)$/
Env.send subcommand.to_sym, rest
@env_output = Env.env_output
@exitcode = Env.exitcode
end
end

When /^a new environment variable "(.*?)" is set as "(.*)"$/ do |name, value|
step "'rhc env set --env #{name}=#{value} --app #{@app.name}' is run"
end

When /^an existing environment variable with name "(.*?)" is unset$/ do |name|
step "'rhc env unset --env #{name} --app #{@app.name}' is run"
end

Given "the existing environment variables are listed" do
step "'rhc env list --app #{@app.name}' is run"
end

Then /^the output environment variables (do not )?include "(.*)"$/ do |exclude, str|
if exclude
@env_output.should_not match(str)
else
@env_output.should match(str)
end
end

0 comments on commit 51e1a17

Please sign in to comment.