summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@rimspace.net>2011-02-01 17:48:54 -0800
committerDaniel Pittman <daniel@rimspace.net>2011-02-17 14:34:34 -0800
commitcb25119b130337e5a9fff0c142ba18c55ebf6059 (patch)
tree931ebfb5740c0d92af17a0dae7bf9389a91ee7af /spec/unit
parentea2948395e4eed1a33f767df60ae28133c94442e (diff)
downloadfacter-cb25119b130337e5a9fff0c142ba18c55ebf6059.tar.gz
facter-cb25119b130337e5a9fff0c142ba18c55ebf6059.tar.xz
facter-cb25119b130337e5a9fff0c142ba18c55ebf6059.zip
(#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 <matt@puppetlabs.com> Paired-With: Max Martin <max@puppetlabs.com>
Diffstat (limited to 'spec/unit')
-rwxr-xr-xspec/unit/ipaddress6_spec.rb36
1 files changed, 36 insertions, 0 deletions
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