From 69010b727295fcdf62b2bd1178165514d281144b Mon Sep 17 00:00:00 2001 From: Alex Moore Date: Wed, 30 Nov 2016 15:30:31 -0500 Subject: [PATCH] Add ts codec unit tests for blobs --- src/riak_pb_ts_codec.erl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/riak_pb_ts_codec.erl b/src/riak_pb_ts_codec.erl index e64dd9d6..a122145a 100644 --- a/src/riak_pb_ts_codec.erl +++ b/src/riak_pb_ts_codec.erl @@ -307,6 +307,7 @@ decode_ts_range(#tsrange{field_name = FieldName, encode_cells_test() -> %% Correct cells ?assertEqual(#tscell{varchar_value = <<"Foo">>}, encode_cell({varchar, <<"Foo">>})), + ?assertEqual(#tscell{varchar_value = <<0,1,2,3>>}, encode_cell({blob, <<0,1,2,3>>})), ?assertEqual(#tscell{sint64_value = 64}, encode_cell({sint64, 64})), ?assertEqual(#tscell{timestamp_value = 64}, encode_cell({timestamp, 64})), ?assertEqual(#tscell{boolean_value = true}, encode_cell({boolean, true})), @@ -315,6 +316,7 @@ encode_cells_test() -> %% Null Cells ?assertEqual(#tscell{}, encode_cell({varchar, []})), + ?assertEqual(#tscell{}, encode_cell({blob, []})), ?assertEqual(#tscell{}, encode_cell({sint64, []})), ?assertEqual(#tscell{}, encode_cell({timestamp, []})), ?assertEqual(#tscell{}, encode_cell({boolean, []})), @@ -332,6 +334,7 @@ encode_row_test() -> ?assertEqual( #tsrow{cells = [ #tscell{varchar_value = <<"Foo">>}, + #tscell{varchar_value = <<0,1,2,3>>}, #tscell{sint64_value = 64}, #tscell{timestamp_value = 42}, #tscell{boolean_value = false}, @@ -339,11 +342,11 @@ encode_row_test() -> #tscell{} ]}, encode_row( - [varchar, sint64, timestamp, boolean, double, varchar], - [<<"Foo">>, 64, 42, false, 42.2, []] + [varchar, blob, sint64, timestamp, boolean, double, varchar], + [<<"Foo">>, <<0,1,2,3>>, 64, 42, false, 42.2, []] )), - ?assertError(function_clause, encode_row([], [<<"Foo">>, 64, 42, false, 42.2, []])), - ?assertError(function_clause, encode_row([varchar, sint64, timestamp], [<<"Foo">>, 64, 42, false, 42.2, []])). + ?assertError(function_clause, encode_row([], [<<"Foo">>, <<0,1,2,3>>, 64, 42, false, 42.2, []])), + ?assertError(function_clause, encode_row([varchar, sint64, timestamp], [<<"Foo">>, <<0,1,2,3>>, 64, 42, false, 42.2, []])). encode_rows_test() -> ?assertEqual( @@ -364,6 +367,7 @@ encode_rows_test() -> encode_field_type_test() -> ?assertEqual('VARCHAR', encode_field_type(varchar)), + ?assertEqual('BLOB', encode_field_type(blob)), ?assertEqual('SINT64',encode_field_type(sint64)), ?assertEqual('TIMESTAMP',encode_field_type(timestamp)), ?assertEqual('BOOLEAN',encode_field_type(boolean)), @@ -371,6 +375,7 @@ encode_field_type_test() -> decode_cell_test() -> ?assertEqual([<<"Foo">>], decode_cells([#tscell{varchar_value = <<"Foo">>}],[])), + ?assertEqual([<<0,1,2,3>>], decode_cells([#tscell{varchar_value = <<0,1,2,3>>}],[])), ?assertEqual([42], decode_cells([#tscell{sint64_value = 42}],[])), ?assertEqual([64], decode_cells([#tscell{timestamp_value = 64}],[])), ?assertEqual([false], decode_cells([#tscell{boolean_value = false}],[])),