Skip to content

Commit b8ea47a

Browse files
committed
test: pin the sink against silent read failures
Greptile flagged the JS counterpart for reading every failure as an empty sink, which lets the deduplication phase forget the effect id and still pass. The Ruby sink already rescues only Errno::ENOENT, and the Ruby effect worker already fails when no effect became claimable, so neither defect exists here. Both properties were incidental until now. These two tests make them deliberate: a truncated JSON file and a path that is a directory must raise rather than read as a first run. Widening the rescue to StandardError fails both.
1 parent abe93f0 commit b8ea47a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/unit/at_least_once_sink_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ class AtLeastOnceSinkTest < ActiveSupport::TestCase
4242
assert_equal [], AtLeastOnceSink.read(File.join(directory, "missing.json"))
4343
end
4444
end
45+
46+
test "refuses to read a damaged sink as an empty one" do
47+
Dir.mktmpdir do |directory|
48+
path = File.join(directory, "sink.json")
49+
File.write(path, "{ deliveries: ")
50+
51+
assert_raises(JSON::ParserError) { AtLeastOnceSink.read(path) }
52+
end
53+
end
54+
55+
test "refuses to read an unreadable sink as an empty one" do
56+
Dir.mktmpdir do |directory|
57+
assert_raises(Errno::EISDIR) { AtLeastOnceSink.read(directory) }
58+
end
59+
end
4560
end

0 commit comments

Comments
 (0)