Skip to content

Commit fb6f128

Browse files
Andrii Chebukinxperiandri
Andrii Chebukin
authored andcommitted
Fixed test projects running on incorrect ports, added local introspection update in build.fsx
1 parent a73b688 commit fb6f128

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

FSharp.Data.GraphQL.Integration.sln

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26124.0
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.33312.197
55
MinimumVisualStudioVersion = 15.0.26124.0
66
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Data.GraphQL.IntegrationTests", "tests\FSharp.Data.GraphQL.IntegrationTests\FSharp.Data.GraphQL.IntegrationTests.fsproj", "{09D910E6-94EF-46AF-94DF-10A9FEC837C0}"
77
EndProject
@@ -14,6 +14,9 @@ EndProject
1414
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{BDE03396-2ED6-4153-B94C-351BAB3F67BD}"
1515
EndProject
1616
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BA7F22E2-D411-4229-826B-F55FF171D12A}"
17+
ProjectSection(SolutionItems) = preProject
18+
build.fsx = build.fsx
19+
EndProjectSection
1720
EndProject
1821
Global
1922
GlobalSection(SolutionConfigurationPlatforms) = preSolution

FSharp.Data.GraphQL.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
141141
global.json = global.json
142142
LICENSE.txt = LICENSE.txt
143143
Packages.props = Packages.props
144+
Prepare template project for packing.ps1 = Prepare template project for packing.ps1
144145
README.md = README.md
145146
RELEASE_NOTES.md = RELEASE_NOTES.md
146147
EndProjectSection

build.fsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
open System.Net.Http
2+
3+
14
#r "nuget: Fake.Api.GitHub"
25
#r "nuget: Fake.Core.ReleaseNotes"
36
#r "nuget: Fake.Core.Target"
@@ -72,7 +75,7 @@ Target.create "Build" <| fun _ ->
7275
Configuration = DotNet.BuildConfiguration.Release
7376
MSBuildParams = { o.MSBuildParams with DisableInternalBinLog = true } })
7477

75-
let startGraphQLServer (project : string) (streamRef : DataRef<Stream>) =
78+
let startGraphQLServer (project : string) port (streamRef : DataRef<Stream>) =
7679
DotNet.build
7780
(fun options ->
7881
{ options with
@@ -90,7 +93,7 @@ let startGraphQLServer (project : string) (streamRef : DataRef<Stream>) =
9093
</> DotNetMoniker
9194
</> (projectName + ".dll")
9295

93-
CreateProcess.fromRawCommandLine "dotnet" $"{serverExe} --urls=http://localhost:8086/"
96+
CreateProcess.fromRawCommandLine "dotnet" $"{serverExe} --urls=http://localhost:%i{port}/"
9497
|> CreateProcess.withStandardInput (CreatePipe streamRef)
9598
|> Proc.start
9699
|> ignore
@@ -123,7 +126,7 @@ Target.create "StartStarWarsServer" <| fun _ ->
123126
</> "star-wars-api"
124127
</> "FSharp.Data.GraphQL.Samples.StarWarsApi.fsproj"
125128

126-
startGraphQLServer project starWarsServerStream
129+
startGraphQLServer project 8086 starWarsServerStream
127130

128131
Target.createFinal "StopStarWarsServer" <| fun _ ->
129132
try
@@ -141,14 +144,23 @@ Target.create "StartIntegrationServer" <| fun _ ->
141144
</> "FSharp.Data.GraphQL.IntegrationTests.Server"
142145
</> "FSharp.Data.GraphQL.IntegrationTests.Server.fsproj"
143146

144-
startGraphQLServer project integrationServerStream
147+
startGraphQLServer project 8085 integrationServerStream
145148

146149
Target.createFinal "StopIntegrationServer" <| fun _ ->
147150
try
148151
integrationServerStream.Value.Write ([| 0uy |], 0, 1)
149152
with e ->
150153
printfn "%s" e.Message
151154

155+
Target.create "UpdateIntrospectionFile" <| fun _ ->
156+
let client = new HttpClient ()
157+
let result = client.GetAsync("http://localhost:8086").Result
158+
let file = new FileStream("tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json", FileMode.Create, FileAccess.Write, FileShare.None)
159+
result.Content.CopyTo(file, null, System.Threading.CancellationToken.None)
160+
file.Close()
161+
result.Dispose()
162+
client.Dispose()
163+
152164
Target.create "RunUnitTests" <| fun _ ->
153165
runTests "tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj"
154166

@@ -249,6 +261,7 @@ Target.create "PackAll" ignore
249261
==> "RunUnitTests"
250262
==> "StartStarWarsServer"
251263
==> "StartIntegrationServer"
264+
==> "UpdateIntrospectionFile"
252265
==> "RunIntegrationTests"
253266
==> "All"
254267
=?> ("GenerateDocs", Environment.environVar "APPVEYOR" = "True")

tests/FSharp.Data.GraphQL.IntegrationTests.Server/Program.fs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
namespace FSharp.Data.GraphQL.IntegrationTests.Server
1+
namespace FSharp.Data.GraphQL.IntegrationTests.Server
22

33
open Microsoft.AspNetCore
44
open Microsoft.AspNetCore.Hosting
55

66
module Program =
77
let exitCode = 0
88

9-
let [<Literal>] BaseAddress = "localhost:8085"
10-
119
let buildWebHost args =
1210
WebHost
1311
.CreateDefaultBuilder(args)
1412
.UseStartup<Startup>()
15-
.UseUrls(sprintf "http://%s" BaseAddress)
1613

1714
[<EntryPoint>]
1815
let main args =

0 commit comments

Comments
 (0)