Class: ProfileCli

Inherits:
Minitest::Test
  • Object
show all
Includes:
CorePluginFunctionalHelper
Defined in:
lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb

Constant Summary

Constants included from CorePluginFunctionalHelper

CorePluginFunctionalHelper::TRAIN_CONNECTION

Instance Method Summary collapse

Methods included from CorePluginFunctionalHelper

#__find_plugin_path_from_caller, #__make_empty_plugin_file_data_structure, #__make_plugin_file_data_structure_with_path, #run_inspec_process, #run_inspec_process_with_this_plugin

Instance Method Details

#setupObject



7
8
9
10
11
# File 'lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb', line 7

def setup
  @tmpdir = Dir.mktmpdir
  @habitat_profile = File.join(@tmpdir, "habitat-profile")
  run_inspec_process("init profile " + @habitat_profile)
end

#teardownObject



13
14
15
# File 'lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb', line 13

def teardown
  FileUtils.remove_entry_secure(@tmpdir)
end

#test_setup_subcommandObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb', line 17

def test_setup_subcommand
  result = run_inspec_process("habitat profile setup " + @habitat_profile + " --log-level debug")

  # Command creates only expected files
  base_dir = File.join(@tmpdir, "habitat-profile", "habitat")
  files = %w{
    plan.sh
  }
  actual_files = Dir.glob(File.join(base_dir, "**/*"))
  expected_files = files.map { |x| File.join(base_dir, x) }
  assert_equal actual_files.sort, expected_files.sort

  # Command runs without error
  assert_empty result.stderr

  assert_exit_code 0, result
end