Skip to content

Commit

Permalink
Add tests for find_hardlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
richardc committed Mar 16, 2018
1 parent 19ce149 commit 92707fb
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion spec/unit/git_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,35 @@ module Omnibus
end

describe "#find_hardlinks" do
pending
let(:regular_file_stat) do
stat = double(File::Stat)
allow(stat).to receive(:ftype).and_return(:file)
allow(stat).to receive(:nlink).and_return(1)
stat
end

let(:hardlinked_file_stat) do
stat = double(File::Stat)
allow(stat).to receive(:ftype).and_return(:file)
allow(stat).to receive(:nlink).and_return(2)
allow(stat).to receive(:dev).and_return(5)
allow(stat).to receive(:ino).and_return(25)
stat
end

before do
allow(File).to receive(:stat).and_return(regular_file_stat)
allow(File).to receive(:stat).with("foo").and_return(hardlinked_file_stat)
allow(File).to receive(:stat).with("bar").and_return(hardlinked_file_stat)

allow(Omnibus::FileSyncer).to receive(:all_files_under).and_return(
%w{ foo bar baz quux }
)
end

it "returns some hardlinks" do
expect(ipc.find_hardlinks).to eq({ "foo" => ["bar"] })
end
end

describe "#restore_hardlinks" do
Expand Down

0 comments on commit 92707fb

Please sign in to comment.