Skip to content

Commit

Permalink
Merge pull request basho#26 from basho/sdc-pb-iolists
Browse files Browse the repository at this point in the history
Fix bug with protobuffs encoding tests
  • Loading branch information
seancribbs committed Dec 21, 2012
2 parents 2ce4a8d + e20de25 commit e9d8c36
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions proto_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def finalize_options(self):
if self.protoc is None:
self.protoc = find_executable('protoc')
if self.protoc is None:
raise RuntimeError, "No protoc compiler was found!"
raise RuntimeError("No protoc compiler was found!")

def run(self):
for protofile in self.get_proto_files():
Expand Down Expand Up @@ -84,7 +84,7 @@ def generate_proto(self, source, outputdir):
source ]
result = self.spawn(protoc_command, 0)
if result is not None and result[1] is not 0:
raise SystemError, "protoc command failed: '%s'" % protoc_command.join(' ')
raise SystemError("protoc command failed: '%s'" % protoc_command.join(' '))

# Inject our .proto compiler into the front of the build commands
build.sub_commands.insert(0, ('build_proto', None))
31 changes: 15 additions & 16 deletions test/encoding_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pb_test_() ->
Value = <<"test value">>,
{MetaData2, Value2} = riak_pb_kv_codec:decode_content(
riak_kv_pb:decode_rpbcontent(
riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value})))),
iolist_to_binary(riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value}))))),
?assertEqual(lists:sort(dict:to_list(MetaData)), lists:sort(dict:to_list(MetaData2))),
?assertEqual(Value, Value2)
end)},
Expand All @@ -38,8 +38,8 @@ pb_test_() ->
{OutputMD, _} = lists:unzip(
[riak_pb_kv_codec:decode_content(
riak_kv_pb:decode_rpbcontent(
riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MD, Value})))) ||
iolist_to_binary(riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MD, Value}))))) ||
MD <- InputMD]),
MdSame1 = (lists:sort(dict:to_list(lists:nth(1, OutputMD))) =:=
lists:sort(dict:to_list(lists:nth(2, OutputMD)))),
Expand All @@ -57,8 +57,8 @@ pb_test_() ->
Value = <<"test value">>,
{OutputMD, _} = riak_pb_kv_codec:decode_content(
riak_kv_pb:decode_rpbcontent(
riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({InputMD, Value})))),
iolist_to_binary(riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({InputMD, Value}))))),
?assertEqual(ExpectedMD, dict:to_list(OutputMD))
end)},
{"empty content encode decode",
Expand All @@ -67,8 +67,8 @@ pb_test_() ->
Value = <<"test value">>,
{MetaData2, Value2} = riak_pb_kv_codec:decode_content(
riak_kv_pb:decode_rpbcontent(
riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value})))),
iolist_to_binary(riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value}))))),
?assertEqual([], dict:to_list(MetaData2)),
?assertEqual(Value, Value2)
end)},
Expand All @@ -78,8 +78,8 @@ pb_test_() ->
Value = <<"test value">>,
{MetaData2, Value2} = riak_pb_kv_codec:decode_content(
riak_kv_pb:decode_rpbcontent(
riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value})))),
iolist_to_binary(riak_kv_pb:encode_rpbcontent(
riak_pb_kv_codec:encode_content({MetaData, Value}))))),
?assertEqual([], dict:to_list(MetaData2)),
?assertEqual(Value, Value2)
end)},
Expand All @@ -93,8 +93,8 @@ pb_test_() ->
{allow_mult, true}],
Props2 = riak_pb_kv_codec:decode_bucket_props(
riak_kv_pb:decode_rpbbucketprops(
riak_kv_pb:encode_rpbbucketprops(
riak_pb_kv_codec:encode_bucket_props(Props)))),
iolist_to_binary(riak_kv_pb:encode_rpbbucketprops(
riak_pb_kv_codec:encode_bucket_props(Props))))),
MdSame = (lists:sort(Props) =:=
lists:sort(Props2)),
?assertEqual(true, MdSame)
Expand All @@ -105,14 +105,13 @@ pb_test_() ->
{allow_mult, false}],
Props2 = riak_pb_kv_codec:decode_bucket_props(
riak_kv_pb:decode_rpbbucketprops(
riak_kv_pb:encode_rpbbucketprops(
riak_pb_kv_codec:encode_bucket_props(Props)))),
iolist_to_binary(riak_kv_pb:encode_rpbbucketprops(
riak_pb_kv_codec:encode_bucket_props(Props))))),
MdSame = (lists:sort(Props) =:=
lists:sort(Props2)),
?assertEqual(true, MdSame)
end)}
]
.
].


msg_code_encode_decode(N) ->
Expand Down

0 comments on commit e9d8c36

Please sign in to comment.