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
12
# File 'lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb', line 7

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

#teardownObject



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

def teardown
  FileUtils.remove_entry_secure(@tmpdir)
end

#test_setup_subcommandObject



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

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

  # Command runs without error
  assert_empty result.stderr
  assert_equal 0, result.exit_status

  # Command creates only expected files
  base_dir = File.join(@tmpdir, "habitat-profile", "habitat")
  files = %w{
    default.toml
    plan.sh
    config
    config/inspec_exec_config.json
    hooks
    hooks/run
  }
  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
end