-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Facilitate running load tests inside WebHost (#55)
* Extract Store CompositionRoot/Builders to common project so Web and CLI can share * Add Web App Test target to CLI
- Loading branch information
Showing
24 changed files
with
935 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ | |
|
||
<Target Name="Build" DependsOnTargets="VSTest;Pack" /> | ||
|
||
</Project> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module Equinox.Cli.Clients | ||
|
||
open Domain | ||
open Equinox.Cli.Infrastructure | ||
open System | ||
open System.Net | ||
open System.Net.Http | ||
|
||
type Session(client: HttpClient, clientId: ClientId) = | ||
|
||
member __.Send(req : HttpRequestMessage) : Async<HttpResponseMessage> = | ||
let req = req |> HttpReq.withHeader "COMPLETELY_INSECURE_CLIENT_ID" clientId.Value | ||
client.Send(req) | ||
|
||
type Favorited = { date: System.DateTimeOffset; skuId: SkuId } | ||
|
||
type FavoritesClient(session: Session) = | ||
|
||
member __.Favorite(skus: SkuId[]) = async { | ||
let request = HttpReq.post () |> HttpReq.withPath "api/favorites" |> HttpReq.withJsonNet skus | ||
let! response = session.Send request | ||
do! response.EnsureStatusCode(HttpStatusCode.NoContent) | ||
} | ||
|
||
member __.List = async { | ||
let request = HttpReq.get () |> HttpReq.withPath "api/favorites" | ||
let! response = session.Send request | ||
return! response |> HttpRes.deserializeOkJsonNet<Favorited[]> | ||
} | ||
|
||
type Saved = { skuId : SkuId; dateSaved : DateTimeOffset } | ||
|
||
type SavesClient(session: Session) = | ||
|
||
// this (returning a bool indicating whether it got saved) is fine for now | ||
// IRL we don't want to be leaning on the fact we get a 400 when we exceed the max imems limit as a core API design element | ||
member __.Save(skus: SkuId[]) : Async<bool> = async { | ||
let request = HttpReq.post () |> HttpReq.withPath "api/saves" |> HttpReq.withJsonNet skus | ||
let! response = session.Send request | ||
if response.StatusCode = HttpStatusCode.BadRequest then | ||
return false | ||
else | ||
do! response.EnsureStatusCode(HttpStatusCode.NoContent) | ||
return true | ||
} | ||
|
||
member __.Remove(skus: SkuId[]) : Async<unit> = async { | ||
let request = HttpReq.delete () |> HttpReq.withPath "api/saves" |> HttpReq.withJsonNet skus | ||
let! response = session.Send request | ||
return! response.EnsureStatusCode(HttpStatusCode.NoContent) | ||
} | ||
|
||
member __.List = async { | ||
let request = HttpReq.get () |> HttpReq.withPath "api/saves" | ||
let! response = session.Send request | ||
return! response |> HttpRes.deserializeOkJsonNet<Saved[]> | ||
} | ||
|
||
type Session with | ||
|
||
member session.Favorites = FavoritesClient session | ||
member session.Saves = SavesClient session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.