Project

General

Profile

Download (1.34 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / test / resources / settings_test.rb @ c06f1783

1
require './test/csv_test_helper'
2
require './lib/hammer_cli_csv'
3

    
4
module Resources
5
  class TestSettingsUsage < MiniTest::Unit::TestCase
6
    def test_usage
7
      start_vcr
8
      set_user 'admin'
9

    
10
      stdout,stderr = capture {
11
        hammer.run(%W{csv settings --help})
12
      }
13
      assert_equal '', stderr
14
      assert_equal stdout, <<-HELP
15
Usage:
16
     csv settings [OPTIONS]
17

18
Options:
19
 --export                      Export current data instead of importing
20
 --file FILE_NAME              CSV file (default to /dev/stdout with --export, otherwise required)
21
 --organization ORGANIZATION   Only process organization matching this name
22
 -h, --help                    print help
23
 -v, --verbose                 be verbose
24
HELP
25
      stop_vcr
26
    end
27
  end
28

    
29
  class TestSettingsImport < MiniTest::Unit::TestCase
30
    def test_update_settings
31
      start_vcr
32
      set_user 'admin'
33

    
34
      name = "settings#{rand(10000)}"
35

    
36
      file = Tempfile.new('settings_test')
37
      # rubocop:disable LineLength
38
      file.write <<-FILE
39
Name,Count,Value
40
idle_timeout,1,60000
41
FILE
42
      file.rewind
43

    
44
      stdout,stderr = capture {
45
        hammer.run(%W{csv settings --verbose --file #{file.path}})
46
      }
47
      stderr.must_equal ''
48
      lines = stdout.split("\n")
49
      assert_equal "Updating setting 'idle_timeout'...done", lines[0]
50
      file.unlink
51
      stop_vcr
52
    end
53
  end
54

    
55
end