improved prune all test

This commit is contained in:
mansimarkaur 2017-08-04 05:47:05 +05:30
parent 5e17d63010
commit 265d43444b

View File

@ -164,20 +164,37 @@ describe Homebrew::Cleanup do
expect(npm_cache).not_to exist expect(npm_cache).not_to exist
end end
it "cleans up files and directories with name containing -- if ARGV prune is all" do it "cleans up all files and directories" do
a = (HOMEBREW_CACHE/"--a") git = (HOMEBREW_CACHE/"gist--git")
b = (HOMEBREW_CACHE/"b") gist = (HOMEBREW_CACHE/"gist")
c = (HOMEBREW_CACHE/"c") svn = (HOMEBREW_CACHE/"gist--svn")
a.mkpath git.mkpath
b.mkpath gist.mkpath
FileUtils.touch c FileUtils.touch svn
allow(ARGV).to receive(:value).with("prune").and_return("all") allow(ARGV).to receive(:value).with("prune").and_return("all")
shutup do begin
described_class.cleanup_cache shutup do
described_class.cleanup_cache
end
expect(git).not_to exist
expect(gist).to exist
expect(svn).not_to exist
ensure
FileUtils.rm_rf(git)
FileUtils.rm_rf(gist)
FileUtils.rm_rf(svn)
end
end
it "raises error when formula name is ambiguous" do
bottle = (HOMEBREW_CACHE/"foo-0.2.bottle.gz")
FileUtils.touch bottle
(HOMEBREW_CELLAR/"foo/foo-0.2").mkpath
begin
described_class.cleanup_cache
ensure
FileUtils.rm_rf(bottle)
end end
expect(a).not_to exist
expect(b).to exist
expect(c).not_to exist
end end
end end
end end