Просмотр исходного кода

Don't send the response immediately when using h2spec

In some cases we were sending a response faster than h2spec
was sending us the test case data, resulting in the request
being processed successfully instead of failing as expected.
Loïc Hoguin 7 лет назад
Родитель
Сommit
843b104fcb
2 измененных файлов с 11 добавлено и 2 удалено
  1. 2 2
      test/h2spec_SUITE.erl
  2. 9 0
      test/handlers/delay_hello_h.erl

+ 2 - 2
test/h2spec_SUITE.erl

@@ -40,8 +40,8 @@ end_per_suite(_Config) ->
 
 init_dispatch() ->
 	cowboy_router:compile([
-		{"localhost", [
-			{"/", hello_h, []}
+		{'_', [
+			{"/", delay_hello_h, 500}
 		]}
 	]).
 

+ 9 - 0
test/handlers/delay_hello_h.erl

@@ -0,0 +1,9 @@
+%% This module sends a hello world response after a delay.
+
+-module(delay_hello_h).
+
+-export([init/2]).
+
+init(Req, Delay) ->
+	timer:sleep(Delay),
+	{ok, cowboy_req:reply(200, #{}, <<"Hello world!">>, Req), Delay}.