<commit_before>﻿module Jim.Tests.QueryIntegrationTests

open System
open System.Text
open System.Net
open System.Net.Http

open Jim.Domain
open Jim.UserModel
open Jim.Tests.IntegrationTestHelpers
open Jim.ApplicationService
open Jim.WebServer

open Suave
open Suave.Types
open Suave.Web
open Suave.Testing
open Fuchu
open Swensen.Unquote.Assertions

[<Tests>]
let commandTests =
    testList "Query integration tests"
        [
        testCase "Should be able to fetch a user" (fun () ->
            let store = storeWithEvents [UserCreated { Id = guid1; Name=Username "<NAME>"; Email=EmailAddress "<EMAIL>"; PasswordHash=PasswordHash "<PASSWORD>"; CreationTime = epoch} ]

            let actual = (run_with' (webApp <| new AppService(store, streamId))) |> req HttpMethod.GET "/users/3C71C09A-2902-4682-B8AB-663432C8867B" None

            test <@ actual.Contains("<NAME>") @>)

        testCase "Should get 404 for non-existent user" (fun () ->
            let store = storeWithEvents []

            let actual_status_code = (run_with' (webApp <| new AppService(store, streamId))) |> req_resp_with_defaults HttpMethod.GET "/users/3C71C09A-2902-4682-B8AB-663432C8867B" None status_code
            
            HttpStatusCode.BadRequest =? actual_status_code)
        ]<commit_msg>oops wrong assertion, test passes<commit_after>﻿module Jim.Tests.QueryIntegrationTests

open System
open System.Text
open System.Net
open System.Net.Http

open Jim.Domain
open Jim.UserModel
open Jim.Tests.IntegrationTestHelpers
open Jim.ApplicationService
open Jim.WebServer

open Suave
open Suave.Types
open Suave.Web
open Suave.Testing
open Fuchu
open Swensen.Unquote.Assertions

[<Tests>]
let commandTests =
    testList "Query integration tests"
        [
        testCase "Should be able to fetch a user" (fun () ->
            let store = storeWithEvents [UserCreated { Id = guid1; Name=Username "Bob Holness"; Email=EmailAddress "<EMAIL>"; PasswordHash=PasswordHash "<PASSWORD>"; CreationTime = epoch} ]

            let actual = (run_with' (webApp <| new AppService(store, streamId))) |> req HttpMethod.GET "/users/3C71C09A-2902-4682-B8AB-663432C8867B" None

            test <@ actual.Contains("<NAME>") @>)

        testCase "Should get 404 for non-existent user" (fun () ->
            let store = storeWithEvents []

            let actual_status_code = (run_with' (webApp <| new AppService(store, streamId))) |> req_resp_with_defaults HttpMethod.GET "/users/3C71C09A-2902-4682-B8AB-663432C8867B" None status_code
            
            HttpStatusCode.NotFound =? actual_status_code)
        ]
{'fraction_non_alphanumeric': 0.10304901582400618, 'fraction_numerical': 0.04013894249324585, 'mean_word_length': 3.4689655172413794, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2250320', 'n_tokens_mistral': 854, 'n_tokens_neox': 792, 'n_words': 205}