Permalink
Browse files

Added parsing module and tests

  • Loading branch information...
Gianfranco Alongi
Gianfranco Alongi committed Mar 21, 2012
1 parent be0ddc0 commit 9f0b639546627e80e5503c53dbd7602802c1a6d9
Showing with 27 additions and 0 deletions.
  1. +10 −0 Three/Solution/src/pubsub_parser.erl
  2. +17 −0 Three/Solution/test/pubsub_parser_tests.erl
@@ -0,0 +1,10 @@
+-module(pubsub_parser).
+-export([parse/1]).
+-include("message.hrl").
+
+-spec(parse(string()) -> #pipe_declaration{}).
+parse("publish-connection") ->
+ #pipe_declaration{type = publish};
+parse("subscribe-connection") ->
+ #pipe_declaration{type = subscribe}.
+
@@ -0,0 +1,17 @@
+-module(pubsub_parser_tests).
+-include_lib("eunit/include/eunit.hrl").
+-include("../src/message.hrl").
+
+parse_publish_selector_test() ->
+ Message = "publish-connection",
+ Res = pubsub_parser:parse(Message),
+ ?assertMatch(#pipe_declaration{type = publish},Res).
+
+parse_subscribe_selector_test() ->
+ Message = "subscribe-connection",
+ Res = pubsub_parser:parse(Message),
+ ?assertMatch(#pipe_declaration{type = subscribe},Res).
+
+
+
+

0 comments on commit 9f0b639

Please sign in to comment.