1
|
require './test/csv_test_helper'
|
2
|
require './lib/hammer_cli_csv'
|
3
|
|
4
|
module Resources
|
5
|
class TestSettingsUsage < MiniTest::Unit::TestCase
|
6
|
|
7
|
def test_usage
|
8
|
set_user 'admin'
|
9
|
|
10
|
stdout,stderr = run_with_vcr do
|
11
|
hammer.run(%W{csv settings --help})
|
12
|
end
|
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 --csv-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
|
end
|
26
|
end
|
27
|
|
28
|
class TestSettingsImport < MiniTest::Unit::TestCase
|
29
|
def test_update_settings
|
30
|
set_user 'admin'
|
31
|
|
32
|
name = "settings#{rand(10000)}"
|
33
|
|
34
|
file = Tempfile.new('settings_test')
|
35
|
|
36
|
file.write <<-FILE
|
37
|
Name,Count,Value
|
38
|
idle_timeout,1,60000
|
39
|
FILE
|
40
|
file.rewind
|
41
|
|
42
|
stdout,stderr = run_with_vcr do
|
43
|
hammer.run(%W{csv settings --verbose --file #{file.path}})
|
44
|
end
|
45
|
stderr.must_equal ''
|
46
|
lines = stdout.split("\n")
|
47
|
assert_equal lines[0], "Updating setting 'idle_timeout'...done"
|
48
|
file.unlink
|
49
|
end
|
50
|
end
|
51
|
|
52
|
end
|