Permalink
Browse files

split tests. Still working on unit tests.

  • Loading branch information...
cadrian committed Oct 26, 2015
1 parent 4950090 commit 5b59895f26d58dde708be6488da5d01055f439b0
Showing with 135 additions and 26 deletions.
  1. +28 −5 test/abstract_test_webclient.e
  2. +2 −21 test/test_webclient_01.e
  3. +32 −0 test/test_webclient_02.e
  4. +37 −0 test/test_webclient_03.e
  5. +36 −0 test/test_webclient_04.e
@@ -46,7 +46,7 @@ feature {}
create mock_client_channel
create mock_server_channel
scenario.expect({FAST_ARRAY[MOCK_EXPECTATION] <<
- mock_channel_factory.new_client_channel(tmpdir).then_return(mock_client_channel.mock),
+ mock_channel_factory.new_client_channel(tmpdir).whenever.then_return(mock_client_channel.mock),
-- mock_channel_factory.new_server_channel.then_return(mock_server_channel.mock)
>>})
@@ -79,13 +79,11 @@ feature {}
do
when_reply ::= args.item(2)
when_reply.item.call([create {REPLY_IS_OPEN}.make("", True)])
- end(?))
+ end(?)),
- mock_client_channel.cleanup
+ mock_client_channel.cleanup.whenever
>>})
-
- scenario.replay_all
end
tmpdir: FIXED_STRING
@@ -124,6 +122,31 @@ feature {}
mock_client_channel: CLIENT_CHANNEL_EXPECT
mock_server_channel: SERVER_CHANNEL_EXPECT
+ expect_splice
+ do
+ scenario.expect({FAST_ARRAY[MOCK_EXPECTATION] <<
+ mock_extern.splice__match(create {MOCK_ANY[INPUT_STREAM]}, create {MOCK_ANY[OUTPUT_STREAM]})
+ .with_side_effect(agent (args: MOCK_ARGUMENTS)
+ local
+ input: MOCK_TYPED_ARGUMENT[INPUT_STREAM]
+ output: MOCK_TYPED_ARGUMENT[OUTPUT_STREAM]
+ do
+ input ::= args.item(1)
+ output ::= args.item(2)
+ from
+ input.item.read_line
+ until
+ input.item.end_of_input
+ loop
+ output.item.put_line(input.item.last_string)
+ input.item.read_line
+ end
+ output.item.put_string(input.item.last_string)
+ output.item.flush
+ end(?))
+ >>})
+ end
+
feature {}
client: WEBCLIENT
View
@@ -25,27 +25,8 @@ feature {}
make
do
prepare_test
-
- assert(call_cgi("GET", "").is_equal("Location:https://test.server.net:8943/open%R%NSet-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%R%N"))
-
- assert(call_cgi("GET", "/").is_equal("Location:https://test.server.net:8943/open%R%NSet-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%R%N"))
-
- assert(call_cgi("GET", "/open").is_equal("Content-Type:text/html%R%N%
- %Cache-Control:%"private,no-store,no-cache%"%R%N%
- %Set-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%
- %%R%N%
- %<html><body></body></html>%R%N"))
-
- assert(call_cgi("GET", "/static/some.txt").is_equal("Content-Type:text/html%R%N%
- %Cache-Control:%"private,no-store,no-cache%"%R%N%
- %Set-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%
- %%R%N%
- %SOME TEXT%R%N"))
-
-
- --assert(call_cgi("GET", "/pass", "[
- -- {"type":"reply","command":"list","error":"","names":["foo","bar"]}
- -- ]").is_equal(""))
+ scenario.replay_all
+ assert(call_cgi("GET", "").is_equal("Location:https://test.server.net:8943/open%R%N%R%N"))
end
end -- class TEST_WEBCLIENT_01
View
@@ -0,0 +1,32 @@
+-- This file is part of pwd.
+-- Copyright (C) 2012-2015 Cyril Adrian <cyril.adrian@gmail.com>
+--
+-- pwd is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, version 3 of the License.
+--
+-- pwd is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with pwd. If not, see <http://www.gnu.org/licenses/>.
+--
+class TEST_WEBCLIENT_02
+
+insert
+ ABSTRACT_TEST_WEBCLIENT
+
+create {}
+ make
+
+feature {}
+ make
+ do
+ prepare_test
+ scenario.replay_all
+ assert(call_cgi("GET", "/").is_equal("Location:https://test.server.net:8943/open%R%N%R%N"))
+ end
+
+end -- class TEST_WEBCLIENT_02
View
@@ -0,0 +1,37 @@
+-- This file is part of pwd.
+-- Copyright (C) 2012-2015 Cyril Adrian <cyril.adrian@gmail.com>
+--
+-- pwd is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, version 3 of the License.
+--
+-- pwd is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with pwd. If not, see <http://www.gnu.org/licenses/>.
+--
+class TEST_WEBCLIENT_03
+
+insert
+ ABSTRACT_TEST_WEBCLIENT
+
+create {}
+ make
+
+feature {}
+ make
+ do
+ prepare_test
+ expect_splice
+ scenario.replay_all
+ assert(call_cgi("GET", "/open").is_equal("Content-Type:text/html%R%N%
+ %Cache-Control:%"private,no-store,no-cache%"%R%N%
+ %Set-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%
+ %%R%N%
+ %<html><body></body></html>%R%N"))
+ end
+
+end -- class TEST_WEBCLIENT_03
View
@@ -0,0 +1,36 @@
+-- This file is part of pwd.
+-- Copyright (C) 2012-2015 Cyril Adrian <cyril.adrian@gmail.com>
+--
+-- pwd is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation, version 3 of the License.
+--
+-- pwd is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with pwd. If not, see <http://www.gnu.org/licenses/>.
+--
+class TEST_WEBCLIENT_04
+
+insert
+ ABSTRACT_TEST_WEBCLIENT
+
+create {}
+ make
+
+feature {}
+ make
+ do
+ prepare_test
+ scenario.replay_all
+ assert(call_cgi("GET", "/static/some.txt").is_equal("Content-Type:text/html%R%N%
+ %Cache-Control:%"private,no-store,no-cache%"%R%N%
+ %Set-Cookie:sessionvault=AAAAAAAAAAAAAAAA; Max-Age=14400; Secure%R%N%
+ %%R%N%
+ %SOME TEXT%R%N"))
+ end
+
+end -- class TEST_WEBCLIENT_04

0 comments on commit 5b59895

Please sign in to comment.