/spec/models/candlepin_consumer_spec.rb
https://github.com/mbacovsky/katello · Ruby · 82 lines · 62 code · 9 blank · 11 comment · 2 complexity · fa30f5cc169d3ddc7aeb8d8e39d57f3b MD5 · raw file
- #
- # Copyright 2014 Red Hat, Inc.
- #
- # This software is licensed to you under the GNU General Public
- # License as published by the Free Software Foundation; either version
- # 2 of the License (GPLv2) or (at your option) any later version.
- # There is NO WARRANTY for this software, express or implied,
- # including the implied warranties of MERCHANTABILITY,
- # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
- # have received a copy of GPLv2 along with this software; if not, see
- # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- require 'katello_test_helper'
- module Katello
- describe Glue::Candlepin::Consumer do
- include OrchestrationHelper
- let(:facts) {
- {
- "net.interface.eth2.broadcast" => "123.123.123.123",
- "net.interface.eth2.ipv4_address" => "192.168.127.5",
- "net.interface.eth2.netmask" => "255.255.255.0",
- "net.interface.eth2.ipv6_address.link" => "fe80::1a03:73ff:fe44:6d94",
- "net.interface.eth0.broadcast" => "123.123.123.123",
- "net.interface.eth0.ipv4_address" => "192.168.127.4",
- "net.interface.eth0.netmask" => "255.255.255.0",
- "net.interface.eth0.ipv6_address.link" => "fe80::2a03:73ff:fe44:6d94",
- "net.interface.em1.broadcast" => "123.123.123.123",
- "net.interface.em1.ipv4_address" => "192.168.1.6",
- "net.interface.em1.netmask" => "255.255.255.0",
- "net.interface.em1.ipv6_address.link" => "fc80::2a03:73ff:fe44:6d94"
- }
- }
- let(:system_name) { 'testing' }
- let(:cp_type) { 'system' }
- let(:uuid) { '1234' }
- let(:description) { 'description' }
- before(:each) do
- @system = System.new(:name => system_name,
- :cp_type => cp_type,
- :facts => facts,
- :description => description,
- :uuid => uuid,
- :serviceLevel => nil)
- end
- describe "the system has a lot of interfaces" do
- it "should have three interfaces" do
- @system.interfaces.size.must_equal(3)
- end
- it "should have an invalid interface" do
- @system.facts["net.interface.em2.ipv4_address"] = nil
- @system.interfaces.size.must_equal(3)
- end
- it "should have an extra interface" do
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
- @system.interfaces.size.must_equal(4)
- end
- it "should have correct interface mappings" do
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
- @system.interfaces.each do |i|
- if i[:name] == 'eth4'
- i[:addr].must_equal('192.168.1.121')
- end
- end
- end
- it "should not flip out about multiple facts" do
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.121'
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.125'
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.123'
- @system.facts["net.interface.eth4.ipv4_address"] = '192.168.1.122'
- @system.interfaces.size.must_equal(4)
- end
- end
- end
- end