diff options
| author | mansimarkaur | 2017-08-05 19:36:35 +0530 | 
|---|---|---|
| committer | mansimarkaur | 2017-08-27 01:18:40 +0530 | 
| commit | 86f7d208d09c4ebb6e4ca3b4cbf82b563307d65d (patch) | |
| tree | 18825dd6fe7d409b403a49e223296dc71dc4dccd /Library/Homebrew/test/cleanup_spec.rb | |
| parent | 134539aa55af17be779bc05fc18e1fabceaeb3d0 (diff) | |
| download | brew-86f7d208d09c4ebb6e4ca3b4cbf82b563307d65d.tar.bz2 | |
Added tests for prune?
Diffstat (limited to 'Library/Homebrew/test/cleanup_spec.rb')
| -rw-r--r-- | Library/Homebrew/test/cleanup_spec.rb | 37 | 
1 files changed, 25 insertions, 12 deletions
diff --git a/Library/Homebrew/test/cleanup_spec.rb b/Library/Homebrew/test/cleanup_spec.rb index 32ffbd357..a66157976 100644 --- a/Library/Homebrew/test/cleanup_spec.rb +++ b/Library/Homebrew/test/cleanup_spec.rb @@ -63,22 +63,11 @@ describe Homebrew::Cleanup do      end    end -  specify "::update_disk_cleanup_size" do -    described_class.instance_eval("@disk_cleanup_size = 0") -    described_class.update_disk_cleanup_size(128) -    expect(described_class.instance_variable_get("@disk_cleanup_size")).to eq(128) -  end -    specify "::disk_cleanup_size" do      described_class.instance_eval("@disk_cleanup_size = 0")      expect(described_class.disk_cleanup_size).to eq(described_class.instance_variable_get("@disk_cleanup_size"))    end -  specify "::unremovable_kegs" do -    described_class.unremovable_kegs -    expect(described_class.instance_variable_get("@unremovable_kegs")).to eq([]) -  end -    specify "::cleanup_formula" do      f1 = Class.new(Testball) do        version "1.0" @@ -178,7 +167,20 @@ describe Homebrew::Cleanup do        end      end -    context "cleaning old files in HOMEBREW_CACHE" do +    it "cleans up VCS checkout directories with modified time < prune time" do +      foo = (HOMEBREW_CACHE/"--foo") +      foo.mkpath +      allow(ARGV).to receive(:value).with("prune").and_return("1") +      allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 2) +      begin +        described_class.cleanup_cache +        expect(foo).not_to exist +      ensure +        FileUtils.rm_rf(foo) +      end +    end + +    context "cleans old files in HOMEBREW_CACHE" do        before(:each) do          @bottle = (HOMEBREW_CACHE/"testball-0.0.1.bottle.tar.gz")          @testball = (HOMEBREW_CACHE/"testball-0.0.1") @@ -216,4 +218,15 @@ describe Homebrew::Cleanup do        end      end    end + +  specify "::prune?" do +    foo = mktmpdir/"foo.rb" +    foo.mkpath +    allow_any_instance_of(Pathname).to receive(:mtime).and_return(Time.now - 60 * 60 * 24 * 2) +    begin +      expect(described_class.prune?(foo, days_default: "1")).to be_truthy +    ensure +      FileUtils.rm_rf(foo) +    end +  end  end  | 
