Skip to content

Commit 7b3e9b8

Browse files
Copilotxperiandri
andcommitted
Replace custom introspection update logic with integration test execution
Agent-Logs-Url: https://github.com/fsprojects/FSharp.Data.GraphQL/sessions/9a7df672-dce9-4c9f-aafd-46ac6e2058c6 Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent c2bd3b5 commit 7b3e9b8

1 file changed

Lines changed: 6 additions & 41 deletions

File tree

build/Program.fs

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module Program
22

33
open System
44
open System.IO
5-
open System.Net.Http
6-
open System.Text.Json
75

86
open Fake.Core
97
open Fake.Core.TargetOperators
@@ -123,26 +121,6 @@ let runTests (project : string) (args : string) =
123121
|> _.WithCommon(DotNetCli.setVersion))
124122
project
125123

126-
let starWarsServerStream = StreamRef.Empty
127-
128-
let [<Literal>] StartStarWarsServerTarget = "StartStarWarsServer"
129-
Target.create StartStarWarsServerTarget <| fun _ ->
130-
Target.activateFinal "StopStarWarsServer"
131-
132-
let project =
133-
"samples"
134-
</> "star-wars-api"
135-
</> "star-wars-api.fsproj"
136-
137-
startGraphQLServer project 8086 starWarsServerStream
138-
139-
let [<Literal>] StopStarWarsServerTarget = "StopStarWarsServer"
140-
Target.createFinal StopStarWarsServerTarget <| fun _ ->
141-
try
142-
starWarsServerStream.Value.Write ([| 0uy |], 0, 1)
143-
with e ->
144-
printfn "%s" e.Message
145-
146124
let integrationTestServerProjectPath =
147125
"tests"
148126
</> "FSharp.Data.GraphQL.IntegrationTests.Server"
@@ -179,26 +157,14 @@ Target.createFinal StopIntegrationServerTarget <| fun _ ->
179157
with e ->
180158
printfn "%s" e.Message
181159

160+
let integrationTestsProjectPath =
161+
"tests"
162+
</> "FSharp.Data.GraphQL.IntegrationTests"
163+
</> "FSharp.Data.GraphQL.IntegrationTests.fsproj"
164+
182165
let [<Literal>] UpdateIntrospectionFileTarget = "UpdateIntrospectionFile"
183166
Target.create UpdateIntrospectionFileTarget <| fun _ ->
184-
let client = new HttpClient ()
185-
(task {
186-
let! result = client.GetAsync ("http://localhost:8086")
187-
let! contentStream = result.Content.ReadAsStreamAsync ()
188-
let! jsonDocument = JsonDocument.ParseAsync contentStream
189-
let file =
190-
new FileStream ("tests/FSharp.Data.GraphQL.IntegrationTests/introspection.json", FileMode.Create, FileAccess.Write, FileShare.None)
191-
let encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping
192-
let jsonWriterOptions = JsonWriterOptions (Indented = true, Encoder = encoder)
193-
let writer = new Utf8JsonWriter (file, jsonWriterOptions)
194-
jsonDocument.WriteTo writer
195-
do! writer.FlushAsync ()
196-
do! writer.DisposeAsync ()
197-
do! file.DisposeAsync ()
198-
result.Dispose ()
199-
})
200-
.Wait ()
201-
client.Dispose ()
167+
runTests integrationTestsProjectPath "--filter FullyQualifiedName~IntrospectionUpdateTests"
202168

203169
let unitTestsProjectPath =
204170
"tests"
@@ -384,7 +350,6 @@ Target.create "PackAndPush" ignore
384350
==> RestoreTarget
385351
==> BuildTarget
386352
==> RunUnitTestsTarget
387-
==> StartStarWarsServerTarget
388353
==> UpdateIntrospectionFileTarget
389354
==> "All"
390355
=?> (GenerateDocsTarget, Environment.environVar "GITHUB_ACTIONS" = "True")

0 commit comments

Comments
 (0)