Skip to content

Commit d0f1caf

Browse files
committedDec 20, 2017
Add a spec for Compression
1 parent 36ba2f7 commit d0f1caf

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

Diff for: ‎lib/kafka/compression.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
module Kafka
66
module Compression
7+
def self.codecs
8+
[:snappy, :gzip, :lz4]
9+
end
10+
711
def self.find_codec(name)
812
case name
913
when nil then nil
1014
when :snappy then SnappyCodec.new
1115
when :gzip then GzipCodec.new
12-
when :lz4 then LZ4Codec.new
16+
when :lz4 then LZ4Codec.new
1317
else raise "Unknown compression codec #{name}"
1418
end
1519
end

Diff for: ‎spec/compression_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
describe Kafka::Compression do
2+
Kafka::Compression.codecs.each do |codec_name|
3+
describe codec_name.to_s do
4+
it "encodes and decodes data" do
5+
data = "yolo"
6+
codec = Kafka::Compression.find_codec(codec_name)
7+
8+
expect(codec.decompress(codec.compress(data))).to eq data
9+
end
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)
Please sign in to comment.