Version 2.1 #41
src
MyWebLog.Data
MyWebLog.Tests/Data
@ -85,7 +85,7 @@ type IPageData =
|
||||
abstract member FindListed : WebLogId -> Task<Page list>
|
||||
|
||||
/// Find a page of pages (displayed in admin section) (excluding meta items, revisions and prior permalinks)
|
||||
abstract member FindPageOfPages : WebLogId -> pageNbr : int -> Task<Page list>
|
||||
abstract member FindPageOfPages : WebLogId -> pageNbr: int -> Task<Page list>
|
||||
|
||||
/// Restore pages from a backup
|
||||
abstract member Restore : Page list -> Task<unit>
|
||||
@ -126,20 +126,20 @@ type IPostData =
|
||||
|
||||
/// Find posts to be displayed on a category list page (excluding revisions and prior permalinks)
|
||||
abstract member FindPageOfCategorizedPosts :
|
||||
WebLogId -> CategoryId list -> pageNbr : int -> postsPerPage : int -> Task<Post list>
|
||||
WebLogId -> CategoryId list -> pageNbr: int -> postsPerPage: int -> Task<Post list>
|
||||
|
||||
/// Find posts to be displayed on an admin page (excluding revisions and prior permalinks)
|
||||
abstract member FindPageOfPosts : WebLogId -> pageNbr : int -> postsPerPage : int -> Task<Post list>
|
||||
abstract member FindPageOfPosts : WebLogId -> pageNbr: int -> postsPerPage: int -> Task<Post list>
|
||||
|
||||
/// Find posts to be displayed on a page (excluding revisions and prior permalinks)
|
||||
abstract member FindPageOfPublishedPosts : WebLogId -> pageNbr : int -> postsPerPage : int -> Task<Post list>
|
||||
abstract member FindPageOfPublishedPosts : WebLogId -> pageNbr: int -> postsPerPage: int -> Task<Post list>
|
||||
|
||||
/// Find posts to be displayed on a tag list page (excluding revisions and prior permalinks)
|
||||
abstract member FindPageOfTaggedPosts :
|
||||
WebLogId -> tag : string -> pageNbr : int -> postsPerPage : int -> Task<Post list>
|
||||
WebLogId -> tag : string -> pageNbr: int -> postsPerPage: int -> Task<Post list>
|
||||
|
||||
/// Find the next older and newer post for the given published date/time (excluding revisions and prior permalinks)
|
||||
abstract member FindSurroundingPosts : WebLogId -> publishedOn : Instant -> Task<Post option * Post option>
|
||||
abstract member FindSurroundingPosts : WebLogId -> publishedOn: Instant -> Task<Post option * Post option>
|
||||
|
||||
/// Restore posts from a backup
|
||||
abstract member Restore : Post list -> Task<unit>
|
||||
|
@ -502,7 +502,9 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
|
||||
withTable Table.Page
|
||||
getAll [ webLogId ] (nameof Page.Empty.WebLogId)
|
||||
filter [ nameof Page.Empty.IsInPageList, true :> obj ]
|
||||
without [ nameof Page.Empty.Text; nameof Page.Empty.PriorPermalinks; nameof Page.Empty.Revisions ]
|
||||
merge (r.HashMap(nameof Page.Empty.Text, "")
|
||||
.With(nameof Page.Empty.PriorPermalinks, [||])
|
||||
.With(nameof Page.Empty.Revisions, [||]))
|
||||
orderBy (nameof Page.Empty.Title)
|
||||
result; withRetryDefault conn
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ let coolPageId = PageId "hgc_BLEZ50SoAWLuPNISvA"
|
||||
/// The published and updated time of the "A cool page" page
|
||||
let coolPagePublished = Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:14:28Z")
|
||||
|
||||
/// The ID of the "Yet Another Page" page
|
||||
let otherPageId = PageId "KouRjvSmm0Wz6TMD8xf67A"
|
||||
|
||||
let ``Add succeeds`` (data: IData) = task {
|
||||
let page =
|
||||
{ Id = PageId "added-page"
|
||||
@ -136,7 +139,6 @@ let ``FindCurrentPermalink succeeds when a page is not found`` (data: IData) = t
|
||||
Expect.isNone link "A permalink should not have been returned"
|
||||
}
|
||||
|
||||
|
||||
let ``FindFullById succeeds when a page is found`` (data: IData) = task {
|
||||
let! page = data.Page.FindFullById coolPageId rootId
|
||||
Expect.isSome page "A page should have been returned"
|
||||
@ -154,3 +156,33 @@ let ``FindFullById succeeds when a page is not found`` (data: IData) = task {
|
||||
let! page = data.Page.FindFullById (PageId "not-there") rootId
|
||||
Expect.isNone page "A page should not have been retrieved"
|
||||
}
|
||||
|
||||
let ``FindFullByWebLog succeeds when pages are found`` (data: IData) = task {
|
||||
let! pages = data.Page.FindFullByWebLog rootId
|
||||
Expect.hasLength pages 2 "There should have been 2 pages returned"
|
||||
pages |> List.iter (fun pg ->
|
||||
Expect.contains [ coolPageId; otherPageId ] pg.Id $"Page ID {pg.Id} unexpected"
|
||||
if pg.Id = coolPageId then
|
||||
Expect.isNonEmpty pg.Metadata "Metadata should have been retrieved"
|
||||
Expect.isNonEmpty pg.PriorPermalinks "Prior permalinks should have been retrieved"
|
||||
Expect.isNonEmpty pg.Revisions "Revisions should have been retrieved")
|
||||
}
|
||||
|
||||
let ``FindFullByWebLog succeeds when pages are not found`` (data: IData) = task {
|
||||
let! pages = data.Page.FindFullByWebLog (WebLogId "does-not-exist")
|
||||
Expect.isEmpty pages "No pages should have been retrieved"
|
||||
}
|
||||
|
||||
let ``FindListed succeeds when pages are found`` (data: IData) = task {
|
||||
let! pages = data.Page.FindListed rootId
|
||||
Expect.hasLength pages 1 "There should have been 1 page returned"
|
||||
Expect.equal pages[0].Id otherPageId "An unexpected page was returned"
|
||||
Expect.equal pages[0].Text "" "Text should not have been returned"
|
||||
Expect.isEmpty pages[0].PriorPermalinks "Prior permalinks should not have been retrieved"
|
||||
Expect.isEmpty pages[0].Revisions "Revisions should not have been retrieved"
|
||||
}
|
||||
|
||||
let ``FindListed succeeds when pages are not found`` (data: IData) = task {
|
||||
let! pages = data.Page.FindListed (WebLogId "none")
|
||||
Expect.isEmpty pages "No pages should have been retrieved"
|
||||
}
|
||||
|
@ -169,6 +169,22 @@ let pageTests = testList "Page" [
|
||||
do! PageDataTests.``FindFullById succeeds when a page is not found`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "FindFullByWebLog" [
|
||||
testTask "succeeds when pages are found" {
|
||||
do! PageDataTests.``FindFullByWebLog succeeds when pages are found`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
do! PageDataTests.``FindFullByWebLog succeeds when pages are not found`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "FindListed" [
|
||||
testTask "succeeds when pages are found" {
|
||||
do! PageDataTests.``FindListed succeeds when pages are found`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
do! PageDataTests.``FindListed succeeds when pages are not found`` (mkData ())
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Drop the throwaway PostgreSQL database
|
||||
|
@ -168,6 +168,22 @@ let pageTests = testList "Page" [
|
||||
do! PageDataTests.``FindFullById succeeds when a page is not found`` data.Value
|
||||
}
|
||||
]
|
||||
testList "FindFullByWebLog" [
|
||||
testTask "succeeds when pages are found" {
|
||||
do! PageDataTests.``FindFullByWebLog succeeds when pages are found`` data.Value
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
do! PageDataTests.``FindFullByWebLog succeeds when pages are not found`` data.Value
|
||||
}
|
||||
]
|
||||
testList "FindListed" [
|
||||
testTask "succeeds when pages are found" {
|
||||
do! PageDataTests.``FindListed succeeds when pages are found`` data.Value
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
do! PageDataTests.``FindListed succeeds when pages are not found`` data.Value
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Drop the throwaway RethinkDB database
|
||||
|
@ -222,6 +222,30 @@ let pageTests = testList "Page" [
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "FindFullByWebLog" [
|
||||
testTask "succeeds when pages are found" {
|
||||
let data = mkData ()
|
||||
try do! PageDataTests.``FindFullByWebLog succeeds when pages are found`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
let data = mkData ()
|
||||
try do! PageDataTests.``FindFullByWebLog succeeds when pages are not found`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "FindListed" [
|
||||
testTask "succeeds when pages are found" {
|
||||
let data = mkData ()
|
||||
try do! PageDataTests.``FindListed succeeds when pages are found`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a pages are not found" {
|
||||
let data = mkData ()
|
||||
try do! PageDataTests.``FindListed succeeds when pages are not found`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Delete the SQLite database
|
||||
|
Loading…
Reference in New Issue
Block a user