Facter.clear clears all cached values and removes all facts from memory where Facter.flush just clears the cached values. This should reduce the time it takes to actually run the unit tests as it all the other facts we're touching won't be removed from memory. Also we only need to do it before the tests, not before and after. Change-Id: I9a24dc9f74cb3b59508b12e63a078068c26c1442
		
			
				
	
	
		
			37 lines
		
	
	
		
			781 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			781 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
require 'spec_helper'
 | 
						|
 | 
						|
describe 'os_workers_small' do
 | 
						|
 | 
						|
  before { Facter.flush }
 | 
						|
 | 
						|
  context 'with processorcount=1' do
 | 
						|
    before do
 | 
						|
      Facter.fact(:processorcount).stubs(:value).returns(1)
 | 
						|
    end
 | 
						|
 | 
						|
    it 'returns a minimum of 2' do
 | 
						|
      expect(Facter.fact(:os_workers_small).value).to eq(2)
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  context 'with processorcount=16' do
 | 
						|
    before do
 | 
						|
      Facter.fact(:processorcount).stubs(:value).returns(16)
 | 
						|
    end
 | 
						|
 | 
						|
    it 'returns processorcount/4' do
 | 
						|
      expect(Facter.fact(:os_workers_small).value).to eq(4)
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  context 'with processorcount=32' do
 | 
						|
    before do
 | 
						|
      Facter.fact(:processorcount).stubs(:value).returns(32)
 | 
						|
    end
 | 
						|
 | 
						|
    it 'returns a maximum of 8' do
 | 
						|
      expect(Facter.fact(:os_workers_small).value).to eq(8)
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 |