Make sure that duplicate requests don't cause the CLI to hang.

This commit is contained in:
Dillon Kearns 2019-10-29 21:45:23 -07:00
parent 8bc59a3d59
commit f44be0d46c
2 changed files with 39 additions and 1 deletions

View File

@ -586,7 +586,17 @@ sendStaticResponsesIfDone errors staticResponses manifest =
(\( path, entry ) -> (\( path, entry ) ->
case entry of case entry of
NotFetched (StaticHttpRequest.Request ( urls, _ )) rawResponses -> NotFetched (StaticHttpRequest.Request ( urls, _ )) rawResponses ->
if List.length urls == (rawResponses |> Dict.keys |> List.length) then if
(urls
|> List.map Pages.Internal.Secrets.useFakeSecrets
|> Set.fromList
|> Set.size
)
== (rawResponses
|> Dict.keys
|> List.length
)
then
False False
else else

View File

@ -119,6 +119,34 @@ all =
} }
] ]
) )
, test "the port sends out when there are duplicate http requests for the same page" <|
\() ->
start
[ ( []
, StaticHttp.map2 (\_ _ -> ())
(StaticHttp.jsonRequest "http://example.com" (Decode.succeed ()))
(StaticHttp.jsonRequest "http://example.com" (Decode.succeed ()))
)
]
|> ProgramTest.simulateHttpOk
"GET"
"http://example.com"
"""null"""
|> ProgramTest.expectOutgoingPortValues
"toJsPort"
(Codec.decoder Main.toJsCodec)
(Expect.equal
[ Main.Success
{ pages =
Dict.fromList
[ ( "/"
, Dict.fromList [ ( "http://example.com", "null" ) ]
)
]
, manifest = manifest
}
]
)
, test "an error is sent out for decoder failures" <| , test "an error is sent out for decoder failures" <|
\() -> \() ->
start start