mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
(spec) Add format spec test
This commit is contained in:
parent
ac12ea69c1
commit
b62cffa2cd
3 changed files with 20 additions and 2 deletions
|
|
@ -64,7 +64,7 @@ class Vmfloaty
|
||||||
|
|
||||||
unless os_types.nil?
|
unless os_types.nil?
|
||||||
response = Pooler.retrieve(verbose, os_types, token, url)
|
response = Pooler.retrieve(verbose, os_types, token, url)
|
||||||
Format.get_hosts(response)
|
puts Format.get_hosts(response)
|
||||||
else
|
else
|
||||||
puts 'You did not provide an OS to get'
|
puts 'You did not provide an OS to get'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,6 @@ class Format
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts host_hash.to_json
|
host_hash.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
18
spec/vmfloaty/format_spec.rb
Normal file
18
spec/vmfloaty/format_spec.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'json'
|
||||||
|
require_relative '../../lib/vmfloaty/format'
|
||||||
|
|
||||||
|
describe Pooler do
|
||||||
|
|
||||||
|
describe "#get_hosts" do
|
||||||
|
before :each do
|
||||||
|
@hostname_hash = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"]},\"debian-7-x86_64\":{\"hostname\":\"zb91y9qbrbf6d3q\"},\"domain\":\"company.com\"}"
|
||||||
|
@format_hash = "{\"debian-7-i386\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"],\"debian-7-x86_64\":\"zb91y9qbrbf6d3q\",\"domain\":\"company.com\"}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "formats a hostname hash into os, hostnames, and domain name" do
|
||||||
|
|
||||||
|
expect(Format.get_hosts(JSON.parse(@hostname_hash))).to eq @format_hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue