Finish page data tests

This commit is contained in:
Daniel J. Summers 2024-01-29 21:20:35 -05:00
parent 0a53e27f22
commit 990b72b1ec
4 changed files with 82 additions and 0 deletions

View File

@ -243,3 +243,29 @@ let ``Update succeeds when the page does not exist`` (data: IData) = task {
let! page = data.Page.FindById pageId rootId
Expect.isNone page "A page should not have been retrieved"
}
let ``UpdatePriorPermalinks succeeds when the page exists`` (data: IData) = task {
let links = [ Permalink "link-1.html"; Permalink "link-1.aspx"; Permalink "link-3.php" ]
let! found = data.Page.UpdatePriorPermalinks otherPageId rootId links
Expect.isTrue found "The permalinks should have been updated"
let! page = data.Page.FindFullById otherPageId rootId
Expect.isSome page "The page should have been found"
Expect.equal page.Value.PriorPermalinks links "The prior permalinks were not correct"
}
let ``UpdatePriorPermalinks succeeds when the page does not exist`` (data: IData) = task {
let! found =
data.Page.UpdatePriorPermalinks (PageId "no-page") WebLogId.Empty
[ Permalink "link-1.html"; Permalink "link-1.aspx"; Permalink "link-3.php" ]
Expect.isFalse found "The permalinks should not have been updated"
}
let ``Delete succeeds when a page is deleted`` (data: IData) = task {
let! deleted = data.Page.Delete coolPageId rootId
Expect.isTrue deleted "The page should have been deleted"
}
let ``Delete succeeds when a page is not deleted`` (data: IData) = task {
let! deleted = data.Page.Delete coolPageId rootId // this was deleted above
Expect.isFalse deleted "A page should not have been deleted"
}

View File

@ -201,6 +201,22 @@ let pageTests = testList "Page" [
do! PageDataTests.``Update succeeds when the page does not exist`` (mkData ())
}
]
testList "UpdatePriorPermalinks" [
testTask "succeeds when the page exists" {
do! PageDataTests.``UpdatePriorPermalinks succeeds when the page exists`` (mkData ())
}
testTask "succeeds when the page does not exist" {
do! PageDataTests.``UpdatePriorPermalinks succeeds when the page does not exist`` (mkData ())
}
]
testList "Delete" [
testTask "succeeds when a page is deleted" {
do! PageDataTests.``Delete succeeds when a page is deleted`` (mkData ())
}
testTask "succeeds when a page is not deleted" {
do! PageDataTests.``Delete succeeds when a page is not deleted`` (mkData ())
}
]
]
/// Drop the throwaway PostgreSQL database

View File

@ -200,6 +200,22 @@ let pageTests = testList "Page" [
do! PageDataTests.``Update succeeds when the page does not exist`` data.Value
}
]
testList "UpdatePriorPermalinks" [
testTask "succeeds when the page exists" {
do! PageDataTests.``UpdatePriorPermalinks succeeds when the page exists`` data.Value
}
testTask "succeeds when the page does not exist" {
do! PageDataTests.``UpdatePriorPermalinks succeeds when the page does not exist`` data.Value
}
]
testList "Delete" [
testTask "succeeds when a page is deleted" {
do! PageDataTests.``Delete succeeds when a page is deleted`` data.Value
}
testTask "succeeds when a page is not deleted" {
do! PageDataTests.``Delete succeeds when a page is not deleted`` data.Value
}
]
]
/// Drop the throwaway RethinkDB database

View File

@ -258,6 +258,30 @@ let pageTests = testList "Page" [
finally dispose data
}
]
testList "UpdatePriorPermalinks" [
testTask "succeeds when the page exists" {
let data = mkData ()
try do! PageDataTests.``UpdatePriorPermalinks succeeds when the page exists`` data
finally dispose data
}
testTask "succeeds when the page does not exist" {
let data = mkData ()
try do! PageDataTests.``UpdatePriorPermalinks succeeds when the page does not exist`` data
finally dispose data
}
]
testList "Delete" [
testTask "succeeds when a page is deleted" {
let data = mkData ()
try do! PageDataTests.``Delete succeeds when a page is deleted`` data
finally dispose data
}
testTask "succeeds when a page is not deleted" {
let data = mkData ()
try do! PageDataTests.``Delete succeeds when a page is not deleted`` data
finally dispose data
}
]
]
/// Delete the SQLite database