Version 2.1 #41

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

View File

@ -18,6 +18,15 @@ let episode1 = PostId "osxMfWGlAkyugUbJ1-xD1g"
/// The published instant for episode 1 /// The published instant for episode 1
let episode1Published = Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:24:01Z") let episode1Published = Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:24:01Z")
/// The ID of podcast episode 2
let episode2 = PostId "l4_Eh4aFO06SqqJjOymNzA"
/// The ID of "Something May Happen" post
let something = PostId "QweKbWQiOkqqrjEdgP9wwg"
/// The ID of "Test Post 1" post
let testPost1 = PostId "RCsCU2puYEmkpzotoi8p4g"
let ``Add succeeds`` (data: IData) = task { let ``Add succeeds`` (data: IData) = task {
let post = let post =
{ Id = PostId "a-new-post" { Id = PostId "a-new-post"
@ -143,3 +152,38 @@ let ``FindCurrentPermalink succeeds when a post is not found`` (data: IData) = t
let! link = data.Post.FindCurrentPermalink [ Permalink "oops/"; Permalink "oops" ] rootId let! link = data.Post.FindCurrentPermalink [ Permalink "oops/"; Permalink "oops" ] rootId
Expect.isNone link "A permalink should not have been returned" Expect.isNone link "A permalink should not have been returned"
} }
let ``FindFullById succeeds when a post is found`` (data: IData) = task {
let! post = data.Post.FindFullById episode1 rootId
Expect.isSome post "A post should have been returned"
let it = post.Value
Expect.equal it.Id episode1 "The wrong post was retrieved"
Expect.equal it.WebLogId rootId "The post's web log did not match the called parameter"
Expect.equal
it.Revisions
[ { AsOf = episode1Published; Text = Html "<p>It's the launch of my new podcast - y'all come listen!" } ]
"Revisions are incorrect"
Expect.equal it.PriorPermalinks [ Permalink "2024/ep-1.html" ] "Prior permalinks are incorrect"
}
let ``FindFullById succeeds when a post is not found`` (data: IData) = task {
let! post = data.Post.FindFullById (PostId "no-post") rootId
Expect.isNone post "A page should not have been retrieved"
}
let ``FindFullByWebLog succeeds when posts are found`` (data: IData) = task {
let! posts = data.Post.FindFullByWebLog rootId
Expect.hasLength posts 4 "There should have been 4 posts returned"
let allPosts = [ testPost1; episode1; episode2; something ]
posts |> List.iter (fun it ->
Expect.contains allPosts it.Id $"Post ID {it.Id} unexpected"
if it.Id = episode1 then
Expect.isNonEmpty it.Metadata "Metadata should have been retrieved"
Expect.isNonEmpty it.PriorPermalinks "Prior permalinks should have been retrieved"
Expect.isNonEmpty it.Revisions "Revisions should have been retrieved")
}
let ``FindFullByWebLog succeeds when posts are not found`` (data: IData) = task {
let! posts = data.Post.FindFullByWebLog (WebLogId "nonexistent")
Expect.isEmpty posts "No posts should have been retrieved"
}

View File

@ -259,6 +259,22 @@ let postTests = testList "Post" [
do! PostDataTests.``FindCurrentPermalink succeeds when a post is not found`` (mkData ()) do! PostDataTests.``FindCurrentPermalink succeeds when a post is not found`` (mkData ())
} }
] ]
testList "FindFullById" [
testTask "succeeds when a post is found" {
do! PostDataTests.``FindFullById succeeds when a post is found`` (mkData ())
}
testTask "succeeds when a post is not found" {
do! PostDataTests.``FindFullById succeeds when a post is not found`` (mkData ())
}
]
testList "FindFullByWebLog" [
testTask "succeeds when posts are found" {
do! PostDataTests.``FindFullByWebLog succeeds when posts are found`` (mkData ())
}
testTask "succeeds when a posts are not found" {
do! PostDataTests.``FindFullByWebLog succeeds when posts are not found`` (mkData ())
}
]
] ]
/// Drop the throwaway PostgreSQL database /// Drop the throwaway PostgreSQL database

View File

@ -258,6 +258,22 @@ let postTests = testList "Post" [
do! PostDataTests.``FindCurrentPermalink succeeds when a post is not found`` data.Value do! PostDataTests.``FindCurrentPermalink succeeds when a post is not found`` data.Value
} }
] ]
testList "FindFullById" [
testTask "succeeds when a post is found" {
do! PostDataTests.``FindFullById succeeds when a post is found`` data.Value
}
testTask "succeeds when a post is not found" {
do! PostDataTests.``FindFullById succeeds when a post is not found`` data.Value
}
]
testList "FindFullByWebLog" [
testTask "succeeds when posts are found" {
do! PostDataTests.``FindFullByWebLog succeeds when posts are found`` data.Value
}
testTask "succeeds when a posts are not found" {
do! PostDataTests.``FindFullByWebLog succeeds when posts are not found`` data.Value
}
]
] ]
/// Drop the throwaway RethinkDB database /// Drop the throwaway RethinkDB database

View File

@ -366,6 +366,30 @@ let postTests = testList "Post" [
finally dispose data finally dispose data
} }
] ]
testList "FindFullById" [
testTask "succeeds when a post is found" {
let data = mkData ()
try do! PostDataTests.``FindFullById succeeds when a post is found`` data
finally dispose data
}
testTask "succeeds when a post is not found" {
let data = mkData ()
try do! PostDataTests.``FindFullById succeeds when a post is not found`` data
finally dispose data
}
]
testList "FindFullByWebLog" [
testTask "succeeds when posts are found" {
let data = mkData ()
try do! PostDataTests.``FindFullByWebLog succeeds when posts are found`` data
finally dispose data
}
testTask "succeeds when a posts are not found" {
let data = mkData ()
try do! PostDataTests.``FindFullByWebLog succeeds when posts are not found`` data
finally dispose data
}
]
] ]
/// Delete the SQLite database /// Delete the SQLite database