Skip to content

Commit

Permalink
Added integration tests for Database.Find.queryObjects.
Browse files Browse the repository at this point in the history
  • Loading branch information
b0wter committed May 11, 2020
1 parent fa9b08a commit d93ed58
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion tests/integration/Databases/Find.fs
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,44 @@ module Find =
| _ -> failwith "This non-matching union case should have been caught earlier! Please fix the test!"
}


type JObjectTests() =
inherit Utilities.PrefilledSingleDatabaseTests("database-find-tests", [ hModel1; hModel2; hModel3 ])

[<Fact>]
member this.``Running a selector matching all elements return three JObjects.`` () =
async {
let selector = condition "myInt" (Equal <| Integer 42)
let expression = createExpression selector
let! result = Databases.Find.queryObjects Initialization.defaultDbProperties this.DbName expression

match result with
| Databases.Find.Result.Success s ->
do s.docs |> should haveLength 3
| _ -> failwith "This non-matching union case should have been caught earlier! Please fix the test!"
}

[<Fact>]
member this.``Running a selector matching two elements returns two JOjects`` () =
async {
let selector = condition "myString" (Equal <| Text "one")
let expression = createExpression selector
let! result = Databases.Find.queryObjects Initialization.defaultDbProperties this.DbName expression

match result with
| Databases.Find.Result.Success s ->
do s.docs |> should haveLength 2
| _ -> failwith "This non-matching union case should have been caught earlier! Please fix the test!"
}

[<Fact>]
member this.``Running a selector matching a single element returns a single JObject``() =
async {
let selector = condition "_id" (Equal <| Id id1)
let expression = createExpression selector
let! result = Databases.Find.queryObjects Initialization.defaultDbProperties this.DbName expression

match result with
| Databases.Find.Result.Success s ->
do s.docs |> should haveLength 1
| _ -> failwith "This non-matching union case should have been caught earlier! Please fix the test!"
}

0 comments on commit d93ed58

Please sign in to comment.