Project

General

Profile

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

hammer-cli-csv / test / hosts_test.rb @ 400832c6

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

    
3
describe 'setup' do
4

    
5
  extend CommandTestHelper
6

    
7
  before :each do
8
    HammerCLI::Settings.load_from_file 'test/config.yml'
9
  end
10

    
11
  context 'Test hosts from setup' do
12

    
13
    it "hammer -v --csv host list --search=name=dhcp129-000.megacorp.com" do
14
      stdout,stderr = capture {
15
        hammer.run(%W{-v --csv host list --search=name=dhcp129-000.megacorp.com})
16
      }
17
      stderr.must_equal ''
18
      stdout.split("\n").length.must_equal 2
19
      stdout.must_match(/.*dhcp129-000\.megacorp\.com.*/)
20

    
21
      host_id = stdout.split("\n")[1].split(",")[0]
22
    end
23

    
24
    let(:host_id) {
25
      stdout,stderr = capture {
26
        hammer.run(%W{-v --csv host list --search=name=dhcp129-000.megacorp.com})
27
      }
28
      host_id = stdout.split("\n")[1].split(",")[0]
29
    }
30

    
31
    it "hammer -v host info --id $id" do
32
      stdout,stderr = capture {
33
        hammer.run(%W{-v host info --id #{host_id}})
34
      }
35
      stderr.must_equal ''
36
      attributes = {}
37
      stdout.split("\n").each do |line|
38
        name,value = line.split(":")
39
        attributes[name.strip] = (value.nil? ? '' : value.strip)
40
      end
41
      attributes['Id'].must_equal host_id
42
      attributes['Name'].must_equal 'dhcp129-000.megacorp.com'
43

    
44
    end
45
  end
46

    
47
end