|
31 | 31 | expect(Utils.generate_os_hash(host_arg)).to be_empty
|
32 | 32 | end
|
33 | 33 | end
|
| 34 | + |
| 35 | + describe '#prettyprint_hosts' do |
| 36 | + let(:host_without_tags) { 'mcpy42eqjxli9g2' } |
| 37 | + let(:host_with_tags) { 'aiydvzpg23r415q' } |
| 38 | + let(:url) { 'http://pooler.example.com' } |
| 39 | + |
| 40 | + let(:host_info_with_tags) do |
| 41 | + { |
| 42 | + host_with_tags => { |
| 43 | + "template" => "redhat-7-x86_64", |
| 44 | + "lifetime" => 48, |
| 45 | + "running" => 7.67, |
| 46 | + "tags" => { |
| 47 | + "user" => "bob", |
| 48 | + "role" => "agent" |
| 49 | + }, |
| 50 | + "domain" => "delivery.puppetlabs.net" |
| 51 | + } |
| 52 | + } |
| 53 | + end |
| 54 | + |
| 55 | + let(:host_info_without_tags) do |
| 56 | + { |
| 57 | + host_without_tags => { |
| 58 | + "template" => "ubuntu-1604-x86_64", |
| 59 | + "lifetime" => 12, |
| 60 | + "running" => 9.66, |
| 61 | + "domain" => "delivery.puppetlabs.net" |
| 62 | + } |
| 63 | + } |
| 64 | + end |
| 65 | + |
| 66 | + let(:output_with_tags) { "- #{host_with_tags}.delivery.puppetlabs.net (redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)" } |
| 67 | + let(:output_without_tags) { "- #{host_without_tags}.delivery.puppetlabs.net (ubuntu-1604-x86_64, 9.66/12 hours)" } |
| 68 | + |
| 69 | + it 'prints an output with host fqdn, template and duration info' do |
| 70 | + allow(Utils).to receive(:get_vm_info). |
| 71 | + with(host_without_tags, false, url). |
| 72 | + and_return(host_info_without_tags) |
| 73 | + |
| 74 | + expect(Utils).to receive(:puts).with("Running VMs:") |
| 75 | + expect(Utils).to receive(:puts).with(output_without_tags) |
| 76 | + |
| 77 | + Utils.prettyprint_hosts(host_without_tags, false, url) |
| 78 | + end |
| 79 | + |
| 80 | + it 'prints an output with host fqdn, template, duration info, and tags when supplied' do |
| 81 | + allow(Utils).to receive(:get_vm_info). |
| 82 | + with(host_with_tags, false, url). |
| 83 | + and_return(host_info_with_tags) |
| 84 | + |
| 85 | + expect(Utils).to receive(:puts).with("Running VMs:") |
| 86 | + expect(Utils).to receive(:puts).with(output_with_tags) |
| 87 | + |
| 88 | + Utils.prettyprint_hosts(host_with_tags, false, url) |
| 89 | + end |
| 90 | + end |
34 | 91 | end
|
0 commit comments