Version 2.1 #41

Merged
danieljsummers merged 123 commits from version-2.1 into main 2024-03-27 00:13:28 +00:00
5 changed files with 99 additions and 4 deletions
Showing only changes of commit c319ff15fd - Show all commits

View File

@ -127,7 +127,7 @@ type RethinkDbData(conn: Net.IConnection, config: DataConfig, log: ILogger<Rethi
log.LogInformation $"Creating index {table}.{priorIdx}..."
do! rethink {
withTable table
indexCreate priorIdx (fun row -> row[priorIdx].Downcase() :> obj) [ Multi ]
indexCreate priorIdx [ Multi ]
write; withRetryOnce; ignoreResult conn
}
// Post needs indexes by category and tag (used for counting and retrieving posts)

View File

@ -85,9 +85,8 @@ let ``FindById succeeds when a page is found`` (data: IData) = task {
Expect.equal pg.AuthorId (WebLogUserId "5EM2rimH9kONpmd2zQkiVA") "Author ID is incorrect"
Expect.equal pg.Title "Page Title" "Title is incorrect"
Expect.equal pg.Permalink (Permalink "a-cool-page.html") "Permalink is incorrect"
Expect.equal
pg.PublishedOn (Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:14:28Z")) "Published On is incorrect"
Expect.equal pg.UpdatedOn (Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:14:28Z")) "Updated On is incorrect"
Expect.equal pg.PublishedOn coolPagePublished "Published On is incorrect"
Expect.equal pg.UpdatedOn coolPagePublished "Updated On is incorrect"
Expect.isFalse pg.IsInPageList "Is in page list flag should not have been set"
Expect.equal pg.Text "<h1 id=\"a-cool-page\">A Cool Page</h1>\n<p>It really is cool!</p>\n" "Text is incorrect"
Expect.hasLength pg.Metadata 2 "There should be 2 metadata items on this page"
@ -109,6 +108,35 @@ let ``FindById succeeds when a page is not found (bad page ID)`` (data: IData) =
Expect.isNone page "The page should not have been retrieved"
}
let ``FindByPermalink succeeds when a page is found`` (data: IData) = task {
let! page = data.Page.FindByPermalink (Permalink "a-cool-page.html") rootId
Expect.isSome page "A page should have been returned"
let pg = page.Value
Expect.equal pg.Id coolPageId "The wrong page was retrieved"
}
let ``FindByPermalink succeeds when a page is not found (incorrect weblog)`` (data: IData) = task {
let! page = data.Page.FindByPermalink (Permalink "a-cool-page.html") (WebLogId "wrong")
Expect.isNone page "The page should not have been retrieved"
}
let ``FindByPermalink succeeds when a page is not found (no such permalink)`` (data: IData) = task {
let! page = data.Page.FindByPermalink (Permalink "1970/no-www-then.html") rootId
Expect.isNone page "The page should not have been retrieved"
}
let ``FindCurrentPermalink succeeds when a page is found`` (data: IData) = task {
let! link = data.Page.FindCurrentPermalink [ Permalink "a-cool-pg.html"; Permalink "a-cool-pg.html/" ] rootId
Expect.isSome link "A permalink should have been returned"
Expect.equal link (Some (Permalink "a-cool-page.html")) "The wrong permalink was retrieved"
}
let ``FindCurrentPermalink succeeds when a page is not found`` (data: IData) = task {
let! link = data.Page.FindCurrentPermalink [ Permalink "blah/"; Permalink "blah" ] rootId
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"

View File

@ -142,6 +142,25 @@ let pageTests = testList "Page" [
do! PageDataTests.``FindById succeeds when a page is not found (bad page ID)`` (mkData ())
}
]
testList "FindByPermalink" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindByPermalink succeeds when a page is found`` (mkData ())
}
testTask "succeeds when a page is not found (incorrect weblog)" {
do! PageDataTests.``FindByPermalink succeeds when a page is not found (incorrect weblog)`` (mkData ())
}
testTask "succeeds when a page is not found (no such permalink)" {
do! PageDataTests.``FindByPermalink succeeds when a page is not found (no such permalink)`` (mkData ())
}
]
testList "FindCurrentPermalink" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindCurrentPermalink succeeds when a page is found`` (mkData ())
}
testTask "succeeds when a page is not found" {
do! PageDataTests.``FindCurrentPermalink succeeds when a page is not found`` (mkData ())
}
]
testList "FindFullById" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindFullById succeeds when a page is found`` (mkData ())

View File

@ -141,6 +141,25 @@ let pageTests = testList "Page" [
do! PageDataTests.``FindById succeeds when a page is not found (bad page ID)`` data.Value
}
]
testList "FindByPermalink" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindByPermalink succeeds when a page is found`` data.Value
}
testTask "succeeds when a page is not found (incorrect weblog)" {
do! PageDataTests.``FindByPermalink succeeds when a page is not found (incorrect weblog)`` data.Value
}
testTask "succeeds when a page is not found (no such permalink)" {
do! PageDataTests.``FindByPermalink succeeds when a page is not found (no such permalink)`` data.Value
}
]
testList "FindCurrentPermalink" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindCurrentPermalink succeeds when a page is found`` data.Value
}
testTask "succeeds when a page is not found" {
do! PageDataTests.``FindCurrentPermalink succeeds when a page is not found`` data.Value
}
]
testList "FindFullById" [
testTask "succeeds when a page is found" {
do! PageDataTests.``FindFullById succeeds when a page is found`` data.Value

View File

@ -181,6 +181,35 @@ let pageTests = testList "Page" [
finally dispose data
}
]
testList "FindByPermalink" [
testTask "succeeds when a page is found" {
let data = mkData ()
try do! PageDataTests.``FindByPermalink succeeds when a page is found`` data
finally dispose data
}
testTask "succeeds when a page is not found (incorrect weblog)" {
let data = mkData ()
try do! PageDataTests.``FindByPermalink succeeds when a page is not found (incorrect weblog)`` data
finally dispose data
}
testTask "succeeds when a page is not found (no such permalink)" {
let data = mkData ()
try do! PageDataTests.``FindByPermalink succeeds when a page is not found (no such permalink)`` data
finally dispose data
}
]
testList "FindCurrentPermalink" [
testTask "succeeds when a page is found" {
let data = mkData ()
try do! PageDataTests.``FindCurrentPermalink succeeds when a page is found`` data
finally dispose data
}
testTask "succeeds when a page is not found" {
let data = mkData ()
try do! PageDataTests.``FindCurrentPermalink succeeds when a page is not found`` data
finally dispose data
}
]
testList "FindFullById" [
testTask "succeeds when a page is found" {
let data = mkData ()