Skip to content

Commit

Permalink
(SERVER-297) Add acceptance tests for env behavior
Browse files Browse the repository at this point in the history
Without this patch there aren't any acceptance tests that validate the
behavior of environment handling.  This patch addresses the problem by
adding a test for the irb and ruby commands.  The gem command is already
tested via the `gem env` command and is difficult to inspect the
environment from since it doesn't evaluate arbitrary code like irb and
ruby can.
  • Loading branch information
Jeff McCune committed Jun 5, 2015
1 parent fcd7aa3 commit b14b711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
@@ -0,0 +1,23 @@
require 'test/unit/assertions'
require 'json'

test_name "Puppetserver subcommand consolidated ENV handling tests."

step "ruby: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present"
on(master, "puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do
env = JSON.parse(stdout)
assert(env['PATH'], "PATH missing")
assert(env['HOME'], "HOME missing")
assert(env['GEM_HOME'], "GEM_HOME missing")
assert(env['JARS_REQUIRE'], "JARS_REQUIRE missing")
assert(env['JARS_NO_REQUIRE'], "JARS_NO_REQUIRE missing")
end

step "irb: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present"
on(master, "puppetserver irb -f -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do
assert_match(/\bPATH\b/, output, "PATH missing")
assert_match(/\bHOME\b/, output, "HOME missing")
assert_match(/\bGEM_HOME\b/, output, "GEM_HOME missing")
assert_match(/\bJARS_REQUIRE\b/, output, "JARS_REQUIRE missing")
assert_match(/\bJARS_NO_REQUIRE\b/, output, "JARS_NO_REQUIRE missing")
end
Expand Up @@ -66,3 +66,6 @@
initial_installed_gems.each do |gem_info|
assert_send([final_installed_gems, :include?, gem_info])
end

step "Verify that gem env operates"
on(master, "#{cli} gem env", :acceptable_exit_codes => [0])

0 comments on commit b14b711

Please sign in to comment.