From cb25119b130337e5a9fff0c142ba18c55ebf6059 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 1 Feb 2011 17:48:54 -0800 Subject: (#2270) add testing for the new ipaddress6 feature This stubs out the platform side of the code, and uses fixtures emitting the right output from the interface configuration tools. Paired-With: Matt Robinson Paired-With: Max Martin --- spec/unit/ipaddress6_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 spec/unit/ipaddress6_spec.rb (limited to 'spec/unit') diff --git a/spec/unit/ipaddress6_spec.rb b/spec/unit/ipaddress6_spec.rb new file mode 100755 index 0000000..d507023 --- /dev/null +++ b/spec/unit/ipaddress6_spec.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + +$basedir = File.expand_path(File.dirname(__FILE__) + '/..') +require File.join($basedir, 'spec_helper') + +require 'facter' + +def ifconfig_fixture(filename) + ifconfig = File.new(File.join($basedir, 'fixtures', 'ifconfig', filename)).read +end + +describe "IPv6 address fact" do + it "should return ipaddress6 information for Darwin" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Darwin') + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). + returns(ifconfig_fixture('darwin_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:223:32ff:fed5:ee34" + end + + it "should return ipaddress6 information for Linux" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('Linux') + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig'). + returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:212:3fff:febe:2201" + end + + it "should return ipaddress6 information for Solaris" do + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/ifconfig -a'). + returns(ifconfig_fixture('sunos_ifconfig_all_with_multiple_interfaces')) + + Facter.value(:ipaddress6).should == "2610:10:20:209:203:baff:fe27:a7c" + end +end -- cgit