Add data test for Page.All

This commit is contained in:
Daniel J. Summers 2024-01-26 17:27:04 -05:00
parent d09a5e1243
commit f701fc9c93
4 changed files with 19 additions and 1 deletions

View File

@ -54,7 +54,7 @@ type IPageData =
/// Add a page
abstract member Add : Page -> Task<unit>
/// Get all pages for the web log (excluding meta items, text, revisions, and prior permalinks)
/// Get all pages for the web log (excluding revisions)
abstract member All : WebLogId -> Task<Page list>
/// Count all pages for the given web log

View File

@ -5,6 +5,9 @@ open MyWebLog
open MyWebLog.Data
open NodaTime
/// The ID of the root web log
let rootId = WebLogId "uSitJEuD3UyzWC9jgOHc8g"
let ``Add succeeds`` (data: IData) = task {
let page =
{ Id = PageId "added-page"
@ -43,3 +46,10 @@ let ``Add succeeds`` (data: IData) = task {
Expect.equal pg.Revisions[0].AsOf page.Revisions[0].AsOf "Revision as of not saved properly"
Expect.equal pg.Revisions[0].Text page.Revisions[0].Text "Revision text not saved properly"
}
let ``All succeeds`` (data: IData) = task {
let! pages = data.Page.All rootId
Expect.hasLength pages 2 "There should have been 4 pages retrieved"
Expect.isEmpty pages[0].Revisions "Page 0 should have had no revisions"
Expect.isEmpty pages[1].Revisions "Page 1 should have had no revisions"
}

View File

@ -105,6 +105,9 @@ let pageTests = testList "Page" [
testTask "Add succeeds" {
do! PageDataTests.``Add succeeds`` (mkData ())
}
testTask "All succeeds" {
do! PageDataTests.``All succeeds`` (mkData ())
}
]
/// Drop the throwaway PostgreSQL database

View File

@ -148,6 +148,11 @@ let pageTests = testList "Page" [
try do! PageDataTests.``Add succeeds`` data
finally dispose data
}
testTask "All succeeds" {
let data = mkData ()
try do! PageDataTests.``All succeeds`` data
finally dispose data
}
]
/// Delete the SQLite database