|
@@ -20,6 +20,27 @@ var (
|
|
|
0x1f, 0x8b,
|
|
|
0x08,
|
|
|
0, 0, 9, 110, 136, 0, 255, 1, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0}
|
|
|
+
|
|
|
+ emptyBulkSnappyMessage = []byte{
|
|
|
+ 180, 47, 53, 209,
|
|
|
+ 0x00,
|
|
|
+ 0x02,
|
|
|
+ 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
+ 0, 0, 0, 42,
|
|
|
+ 130, 83, 78, 65, 80, 80, 89, 0,
|
|
|
+ 0, 0, 0, 1,
|
|
|
+ 0, 0, 0, 1,
|
|
|
+ 0, 0, 0, 22, 52, 0, 0, 25, 1, 16, 14, 227, 138, 104, 118, 25, 15, 13, 1, 8, 1, 0, 0, 62, 26, 0}
|
|
|
+
|
|
|
+ emptyBulkGzipMessage = []byte{
|
|
|
+ 139, 160, 63, 141,
|
|
|
+ 0x00,
|
|
|
+ 0x01,
|
|
|
+ 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
+ 0x00, 0x00, 0x00, 0x27,
|
|
|
+ 0x1f, 0x8b,
|
|
|
+ 0x08,
|
|
|
+ 0, 0, 0, 0, 0, 0, 0, 99, 96, 128, 3, 190, 202, 112, 143, 7, 12, 12, 255, 129, 0, 33, 200, 192, 136, 41, 3, 0, 199, 226, 155, 70, 52, 0, 0, 0}
|
|
|
)
|
|
|
|
|
|
func TestMessageEncoding(t *testing.T) {
|
|
@@ -43,6 +64,9 @@ func TestMessageDecoding(t *testing.T) {
|
|
|
if message.Value != nil {
|
|
|
t.Error("Decoding produced value where there was none.")
|
|
|
}
|
|
|
+ if message.Set != nil {
|
|
|
+ t.Error("Decoding produced set where there was none.")
|
|
|
+ }
|
|
|
|
|
|
testDecodable(t, "empty gzip", &message, emptyGzipMessage)
|
|
|
if message.Codec != CompressionGZIP {
|
|
@@ -55,3 +79,35 @@ func TestMessageDecoding(t *testing.T) {
|
|
|
t.Error("Decoding produced nil or content-ful value where there was an empty array.")
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestMessageDecodingBulkSnappy(t *testing.T) {
|
|
|
+ message := Message{}
|
|
|
+ testDecodable(t, "bulk snappy", &message, emptyBulkSnappyMessage)
|
|
|
+ if message.Codec != CompressionSnappy {
|
|
|
+ t.Errorf("Decoding produced codec %d, but expected %d.", message.Codec, CompressionSnappy)
|
|
|
+ }
|
|
|
+ if message.Key != nil {
|
|
|
+ t.Errorf("Decoding produced key %+v, but none was expected.", message.Key)
|
|
|
+ }
|
|
|
+ if message.Set == nil {
|
|
|
+ t.Error("Decoding produced no set, but one was expected.")
|
|
|
+ } else if len(message.Set.Messages) != 2 {
|
|
|
+ t.Errorf("Decoding produced a set with %d messages, but 2 were expected.", len(message.Set.Messages))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func TestMessageDecodingBulkGzip(t *testing.T) {
|
|
|
+ message := Message{}
|
|
|
+ testDecodable(t, "bulk gzip", &message, emptyBulkGzipMessage)
|
|
|
+ if message.Codec != CompressionGZIP {
|
|
|
+ t.Errorf("Decoding produced codec %d, but expected %d.", message.Codec, CompressionGZIP)
|
|
|
+ }
|
|
|
+ if message.Key != nil {
|
|
|
+ t.Errorf("Decoding produced key %+v, but none was expected.", message.Key)
|
|
|
+ }
|
|
|
+ if message.Set == nil {
|
|
|
+ t.Error("Decoding produced no set, but one was expected.")
|
|
|
+ } else if len(message.Set.Messages) != 2 {
|
|
|
+ t.Errorf("Decoding produced a set with %d messages, but 2 were expected.", len(message.Set.Messages))
|
|
|
+ }
|
|
|
+}
|