spec/unit/memory_spec.rb in facter-1.7.3 vs spec/unit/memory_spec.rb in facter-1.7.4.rc1

- old
+ new

@@ -152,12 +152,26 @@ swapusage = <<SWAP device maj,min total free /dev/hd6 10, 2 512MB 508MB SWAP - Facter::Util::Resolution.stubs(:exec).with('swap -l').returns(swapusage) + Facter::Util::Resolution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage) + svmon = <<SVMON +Unit: KB +-------------------------------------------------------------------------------------- + size inuse free pin virtual available mmode +memory 32768000 9948408 22819592 2432080 4448928 27231828 Ded +pg space 34078720 15000 + + work pers clnt other +pin 1478228 0 0 953852 +in use 4448928 0 5499480 +SVMON + + Facter::Util::Resolution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon) + Facter.collection.internal_loader.load(:memory) end after(:each) do Facter.clear @@ -188,10 +202,19 @@ it "should return the current swap free in MB" do Facter.fact(:swapfree_mb).value.should == "508.00" end end + + it "should return the current memory free in MB" do + Facter.fact(:memoryfree_mb).value.should == "22284.76" + end + + it "should return the current memory size in MB" do + Facter.fact(:memorysize_mb).value.should == "32000.00" + end + end describe "on OpenBSD" do before :each do @@ -262,11 +285,11 @@ before(:each) do sample_swap_line = <<SWAP swapfile dev swaplo blocks free /dev/swap 4294967295,4294967295 16 2097136 2097136 SWAP - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do @@ -291,11 +314,11 @@ sample_swap_line = <<SWAP swapfile dev swaplo blocks free /dev/swap 4294967295,4294967295 16 2097136 2097136 /dev/swap2 4294967295,4294967295 16 2097136 2097136 SWAP - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do Facter.fact(:memorysize_mb).value.should == "2048.00" @@ -314,10 +337,10 @@ end end describe "when no swap exists" do before(:each) do - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns "" + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns "" Facter.collection.internal_loader.load(:memory) end it "should return the current memory size in MB" do