Project

General

Profile

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

hammer-cli-csv / test / job_templates_test.rb @ 5146ac68

1
require File.join(File.dirname(__FILE__), 'csv_test_helper')
2

    
3
describe 'job-templates' do
4

    
5
  extend CommandTestHelper
6

    
7
  context "import" do
8
    it "create job template with input" do
9
      set_user 'admin'
10

    
11
      name = "jobtemplate#{rand(10000)}"
12

    
13
      file = Tempfile.new('job_templates_test')
14
      # rubocop:disable LineLength
15
      file.write <<-FILE
16
"Name","Organizations","Locations","Description","Job Category","Provider","Snippet","Template","Input:Name","Input:Description","Input:Required","Input:Type","Input:Parameters"
17
"#{name}","","","","TEST","SSH","No","<%= input(""command"") %>"
18
"#{name}","","","","","","","","command","command to run","Yes","user",""
19
FILE
20
      # rubocop:enable LineLength
21
      file.rewind
22
      stdout,stderr = capture {
23
        hammer.run(%W{csv job-templates --verbose --file #{file.path}})
24
      }
25
      stderr.must_equal ''
26
      lines = stdout.split("\n")
27
      lines[0].must_equal "Creating job template '#{name}'...done"
28
      lines[1].must_equal "Creating job template input 'command' on '#{name}'...done"
29
      file.unlink
30
    end
31
  end
32
end