Skip to content

Commit

Permalink
Make HaveStringContentSatisfying Async instead of Task
Browse files Browse the repository at this point in the history
  • Loading branch information
Christer van der Meeren committed May 13, 2024
1 parent b4d3cb9 commit 1c7f813
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Release notes
==============

### 1.3.10 (2024-05-13)
### 1.3.11 (2024-05-13)

* Added `string` assertion `BeJsonEquivalentTo`
* Added `HttpResponseMessage` assertion `HaveStringContentSatisfying`. Note that this is async and therefore not
Expand Down
5 changes: 2 additions & 3 deletions src/Faqt.Tests/TestUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module TestUtils
open System
open System.Globalization
open System.Runtime.CompilerServices
open System.Threading.Tasks
open Faqt
open Faqt.AssertionHelpers
open Xunit
Expand All @@ -23,9 +22,9 @@ let assertExnMsg (msg: string) (f: unit -> 'a) =
)


let assertExnMsgAsync (msg: string) (f: unit -> Task) =
let assertExnMsgAsync (msg: string) (f: unit -> Async<unit>) =
task {
let! ex = Assert.ThrowsAsync<AssertionFailedException>(f)
let! ex = Assert.ThrowsAsync<AssertionFailedException>(f >> Async.StartImmediateAsTask >> (fun t -> upcast t))

Assert.Equal(
("\n\n" + msg.ReplaceLineEndings("\n").Trim() + "\n") :> obj, // Cast to obj to force full output
Expand Down
2 changes: 1 addition & 1 deletion src/Faqt/Faqt.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net5.0;net7.0;net8.0</TargetFrameworks>
<Version>1.3.10</Version>
<Version>1.3.11</Version>
<Authors>Christer van der Meeren</Authors>
<Description>A fluent assertion library for F#.</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
8 changes: 4 additions & 4 deletions src/Faqt/HttpResponseMessageAssertions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
open System.Net
open System.Net.Http
open System.Runtime.CompilerServices
open System.Threading.Tasks
open Faqt.AssertionHelpers


Expand Down Expand Up @@ -576,8 +575,8 @@ type HttpResponseMessageAssertions =
t: Testable<HttpResponseMessage>,
assertion: string -> 'ignored,
?because
) : Task =
task {
) : Async<unit> =
async {
use _ = t.Assert(true)

match t.Subject.Content with
Expand All @@ -587,7 +586,8 @@ type HttpResponseMessageAssertions =
.With("Request", t.Subject.RequestMessage)
.Fail(because)
| content ->
let! str = content.ReadAsStringAsync()
let! ct = Async.CancellationToken
let! str = content.ReadAsStringAsync(ct) |> Async.AwaitTask

try
assertion str |> ignore
Expand Down

0 comments on commit 1c7f813

Please sign in to comment.