Skip to content

Commit 0a5c2fe

Browse files
Copilotxperiandri
andauthored
Replace lazy shared test clients with explicit client factory methods
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/e9009367-0c5a-44a7-986e-7b0cfa2a3f94 Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent b23dce3 commit 0a5c2fe

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

tests/FSharp.Data.GraphQL.IntegrationTests/TestHosts.fs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,30 @@ type StarWarsApplicationFactory () =
1414
let private integrationFactory = lazy (new IntegrationServerApplicationFactory ())
1515
let private starWarsFactory = lazy (new StarWarsApplicationFactory ())
1616

17-
let private integrationClient : Lazy<HttpClient> =
18-
lazy (integrationFactory.Value.CreateClient ())
17+
let createIntegrationHttpClient () : HttpClient =
18+
integrationFactory.Value.CreateClient ()
1919

20-
let private starWarsClient : Lazy<HttpClient> =
21-
lazy (starWarsFactory.Value.CreateClient ())
20+
let createStarWarsHttpClient () : HttpClient =
21+
starWarsFactory.Value.CreateClient ()
2222

23-
do
24-
AppDomain.CurrentDomain.ProcessExit.Add(fun _ ->
25-
if integrationClient.IsValueCreated then
26-
integrationClient.Value.Dispose ()
23+
let private getIntegrationServerUrl () =
24+
use client = createIntegrationHttpClient ()
25+
client.BaseAddress.ToString().TrimEnd '/'
2726

28-
if starWarsClient.IsValueCreated then
29-
starWarsClient.Value.Dispose ()
27+
let private getStarWarsServerUrl () =
28+
use client = createStarWarsHttpClient ()
29+
client.BaseAddress.ToString().TrimEnd '/'
3030

31+
do
32+
AppDomain.CurrentDomain.ProcessExit.Add(fun _ ->
3133
if integrationFactory.IsValueCreated then
3234
integrationFactory.Value.Dispose ()
3335

3436
if starWarsFactory.IsValueCreated then
3537
starWarsFactory.Value.Dispose ())
3638

37-
let integrationServerUrl = integrationClient.Value.BaseAddress.ToString().TrimEnd '/'
38-
let starWarsServerUrl = starWarsClient.Value.BaseAddress.ToString().TrimEnd '/'
39+
let integrationServerUrl = getIntegrationServerUrl ()
40+
let starWarsServerUrl = getStarWarsServerUrl ()
3941

40-
let createIntegrationConnection () = new GraphQLClientConnection (integrationClient.Value)
41-
let createStarWarsConnection () = new GraphQLClientConnection (starWarsClient.Value)
42-
let createIntegrationHttpClient () = integrationFactory.Value.CreateClient ()
42+
let createIntegrationConnection () = new GraphQLClientConnection (createIntegrationHttpClient ())
43+
let createStarWarsConnection () = new GraphQLClientConnection (createStarWarsHttpClient ())

0 commit comments

Comments
 (0)