Add web log tests
- Add post-delete rev checks to pg/sqlite
This commit is contained in:
parent
16f7396664
commit
f25426db5c
|
@ -25,7 +25,9 @@ type PostgresWebLogData(log: ILogger) =
|
|||
Custom.nonQuery
|
||||
$"""DELETE FROM {Table.PostComment}
|
||||
WHERE data ->> '{nameof Comment.Empty.PostId}'
|
||||
IN (SELECT id FROM {Table.Post} WHERE {Query.whereDataContains "@criteria"});
|
||||
IN (SELECT data ->> '{nameof Post.Empty.Id}'
|
||||
FROM {Table.Post}
|
||||
WHERE {Query.whereDataContains "@criteria"});
|
||||
DELETE FROM {Table.PostRevision}
|
||||
WHERE post_id IN (SELECT data ->> 'Id' FROM {Table.Post} WHERE {Query.whereDataContains "@criteria"});
|
||||
DELETE FROM {Table.PageRevision}
|
||||
|
|
|
@ -446,7 +446,7 @@ type PostId =
|
|||
|
||||
|
||||
/// A redirection for a previously valid URL
|
||||
[<CLIMutable; NoComparison; NoEquality>]
|
||||
[<CLIMutable>]
|
||||
type RedirectRule = {
|
||||
/// The From string or pattern
|
||||
From: string
|
||||
|
|
|
@ -13,7 +13,7 @@ open NodaTime
|
|||
let private rootId = CategoryDataTests.rootId
|
||||
|
||||
/// The ID of the "A cool page" page
|
||||
let private coolPageId = PageId "hgc_BLEZ50SoAWLuPNISvA"
|
||||
let coolPageId = PageId "hgc_BLEZ50SoAWLuPNISvA"
|
||||
|
||||
/// The published and updated time of the "A cool page" page
|
||||
let private coolPagePublished = Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:14:28Z")
|
||||
|
|
|
@ -19,7 +19,7 @@ let private episode1 = PostId "osxMfWGlAkyugUbJ1-xD1g"
|
|||
let private episode1Published = Instant.FromDateTimeOffset(DateTimeOffset.Parse "2024-01-20T22:24:01Z")
|
||||
|
||||
/// The ID of podcast episode 2
|
||||
let private episode2 = PostId "l4_Eh4aFO06SqqJjOymNzA"
|
||||
let episode2 = PostId "l4_Eh4aFO06SqqJjOymNzA"
|
||||
|
||||
/// The ID of "Something May Happen" post
|
||||
let private something = PostId "QweKbWQiOkqqrjEdgP9wwg"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module PostgresDataTests
|
||||
|
||||
open BitBadger.Documents
|
||||
open BitBadger.Documents.Postgres
|
||||
open Expecto
|
||||
open Microsoft.Extensions.Logging.Abstractions
|
||||
open MyWebLog
|
||||
|
@ -42,7 +42,7 @@ let private freshEnvironment () = task {
|
|||
db <- Some (ThrowawayDatabase.Create $"Host={testHost};Database={testDb};User ID={testUser};Password={testPw}")
|
||||
let source = NpgsqlDataSourceBuilder db.Value.ConnectionString
|
||||
let _ = source.UseNodaTime()
|
||||
Postgres.Configuration.useDataSource (source.Build())
|
||||
Configuration.useDataSource (source.Build())
|
||||
let env = mkData ()
|
||||
do! env.StartUp()
|
||||
// This exercises Restore for all implementations; all tests are dependent on it working as expected
|
||||
|
@ -211,6 +211,12 @@ let private pageTests = testList "Page" [
|
|||
testList "Delete" [
|
||||
testTask "succeeds when a page is deleted" {
|
||||
do! PageDataTests.``Delete succeeds when a page is deleted`` (mkData ())
|
||||
let! revisions =
|
||||
Custom.scalar
|
||||
"SELECT COUNT(*) AS it FROM page_revision WHERE page_id = @id"
|
||||
[ idParam PageDataTests.coolPageId ]
|
||||
toCount
|
||||
Expect.equal revisions 0 "All revisions for the page should have been deleted"
|
||||
}
|
||||
testTask "succeeds when a page is not deleted" {
|
||||
do! PageDataTests.``Delete succeeds when a page is not deleted`` (mkData ())
|
||||
|
@ -351,6 +357,12 @@ let private postTests = testList "Post" [
|
|||
testList "Delete" [
|
||||
testTask "succeeds when a post is deleted" {
|
||||
do! PostDataTests.``Delete succeeds when a post is deleted`` (mkData ())
|
||||
let! revisions =
|
||||
Custom.scalar
|
||||
"SELECT COUNT(*) AS it FROM post_revision WHERE post_id = @id"
|
||||
[ idParam PostDataTests.episode2 ]
|
||||
toCount
|
||||
Expect.equal revisions 0 "All revisions for the post should have been deleted"
|
||||
}
|
||||
testTask "succeeds when a post is not deleted" {
|
||||
do! PostDataTests.``Delete succeeds when a post is not deleted`` (mkData ())
|
||||
|
@ -625,6 +637,69 @@ let private webLogUserTests = testList "WebLogUser" [
|
|||
]
|
||||
]
|
||||
|
||||
let private webLogTests = testList "WebLog" [
|
||||
testTask "Add succeeds" {
|
||||
do! WebLogDataTests.``Add succeeds`` (mkData ())
|
||||
}
|
||||
testTask "All succeeds" {
|
||||
do! WebLogDataTests.``All succeeds`` (mkData ())
|
||||
}
|
||||
testList "FindByHost" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
do! WebLogDataTests.``FindByHost succeeds when a web log is found`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
do! WebLogDataTests.``FindByHost succeeds when a web log is not found`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "FindById" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
do! WebLogDataTests.``FindById succeeds when a web log is found`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
do! WebLogDataTests.``FindById succeeds when a web log is not found`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "UpdateRedirectRules" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log exists`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log does not exist`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "UpdateRssOptions" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateRssOptions succeeds when the web log exists`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateRssOptions succeeds when the web log does not exist`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "UpdateSettings" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateSettings succeeds when the web log exists`` (mkData ())
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateSettings succeeds when the web log does not exist`` (mkData ())
|
||||
}
|
||||
]
|
||||
testList "Delete" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``Delete succeeds when the web log exists`` (mkData ())
|
||||
let! revisions =
|
||||
Custom.scalar
|
||||
"SELECT (SELECT COUNT(*) FROM page_revision) + (SELECT COUNT(*) FROM post_revision) AS it"
|
||||
[]
|
||||
toCount
|
||||
Expect.equal revisions 0 "All revisions should be deleted"
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``Delete succeeds when the web log does not exist`` (mkData ())
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Drop the throwaway PostgreSQL database
|
||||
let private environmentCleanUp = test "Clean Up" {
|
||||
if db.IsSome then db.Value.Dispose()
|
||||
|
@ -642,5 +717,6 @@ let all =
|
|||
themeAssetTests
|
||||
uploadTests
|
||||
webLogUserTests
|
||||
webLogTests
|
||||
environmentCleanUp ]
|
||||
|> testSequenced
|
||||
|
|
|
@ -625,6 +625,63 @@ let private webLogUserTests = testList "WebLogUser" [
|
|||
]
|
||||
]
|
||||
|
||||
let private webLogTests = testList "WebLog" [
|
||||
testTask "Add succeeds" {
|
||||
do! WebLogDataTests.``Add succeeds`` data.Value
|
||||
}
|
||||
testTask "All succeeds" {
|
||||
do! WebLogDataTests.``All succeeds`` data.Value
|
||||
}
|
||||
testList "FindByHost" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
do! WebLogDataTests.``FindByHost succeeds when a web log is found`` data.Value
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
do! WebLogDataTests.``FindByHost succeeds when a web log is not found`` data.Value
|
||||
}
|
||||
]
|
||||
testList "FindById" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
do! WebLogDataTests.``FindById succeeds when a web log is found`` data.Value
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
do! WebLogDataTests.``FindById succeeds when a web log is not found`` data.Value
|
||||
}
|
||||
]
|
||||
testList "UpdateRedirectRules" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log exists`` data.Value
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log does not exist`` data.Value
|
||||
}
|
||||
]
|
||||
testList "UpdateRssOptions" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateRssOptions succeeds when the web log exists`` data.Value
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateRssOptions succeeds when the web log does not exist`` data.Value
|
||||
}
|
||||
]
|
||||
testList "UpdateSettings" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``UpdateSettings succeeds when the web log exists`` data.Value
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``UpdateSettings succeeds when the web log does not exist`` data.Value
|
||||
}
|
||||
]
|
||||
testList "Delete" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
do! WebLogDataTests.``Delete succeeds when the web log exists`` data.Value
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
do! WebLogDataTests.``Delete succeeds when the web log does not exist`` data.Value
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Drop the throwaway RethinkDB database
|
||||
let private environmentCleanUp = testTask "Clean Up" {
|
||||
do! disposeData ()
|
||||
|
@ -642,5 +699,6 @@ let all =
|
|||
themeAssetTests
|
||||
uploadTests
|
||||
webLogUserTests
|
||||
webLogTests
|
||||
environmentCleanUp ]
|
||||
|> testSequenced
|
||||
|
|
|
@ -308,7 +308,14 @@ let private pageTests = testList "Page" [
|
|||
testList "Delete" [
|
||||
testTask "succeeds when a page is deleted" {
|
||||
let data = mkData ()
|
||||
try do! PageDataTests.``Delete succeeds when a page is deleted`` data
|
||||
try
|
||||
do! PageDataTests.``Delete succeeds when a page is deleted`` data
|
||||
let! revisions =
|
||||
(data :?> SQLiteData).Conn.customScalar
|
||||
"SELECT COUNT(*) AS it FROM page_revision WHERE page_id = @id"
|
||||
[ idParam PageDataTests.coolPageId ]
|
||||
toCount
|
||||
Expect.equal revisions 0L "All revisions for the page should have been deleted"
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a page is not deleted" {
|
||||
|
@ -519,7 +526,14 @@ let private postTests = testList "Post" [
|
|||
testList "Delete" [
|
||||
testTask "succeeds when a post is deleted" {
|
||||
let data = mkData ()
|
||||
try do! PostDataTests.``Delete succeeds when a post is deleted`` data
|
||||
try
|
||||
do! PostDataTests.``Delete succeeds when a post is deleted`` data
|
||||
let! revisions =
|
||||
(data :?> SQLiteData).Conn.customScalar
|
||||
"SELECT COUNT(*) AS it FROM post_revision WHERE post_id = @id"
|
||||
[ idParam PostDataTests.episode2 ]
|
||||
toCount
|
||||
Expect.equal revisions 0L "All revisions for the post should have been deleted"
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a post is not deleted" {
|
||||
|
@ -925,6 +939,98 @@ let private webLogUserTests = testList "WebLogUser" [
|
|||
]
|
||||
]
|
||||
|
||||
let private webLogTests = testList "WebLog" [
|
||||
testTask "Add succeeds" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``Add succeeds`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "All succeeds" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``All succeeds`` data
|
||||
finally dispose data
|
||||
}
|
||||
testList "FindByHost" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``FindByHost succeeds when a web log is found`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``FindByHost succeeds when a web log is not found`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "FindById" [
|
||||
testTask "succeeds when a web log is found" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``FindById succeeds when a web log is found`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when a web log is not found" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``FindById succeeds when a web log is not found`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "UpdateRedirectRules" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log exists`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateRedirectRules succeeds when the web log does not exist`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "UpdateRssOptions" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateRssOptions succeeds when the web log exists`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateRssOptions succeeds when the web log does not exist`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "UpdateSettings" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateSettings succeeds when the web log exists`` data
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``UpdateSettings succeeds when the web log does not exist`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
testList "Delete" [
|
||||
testTask "succeeds when the web log exists" {
|
||||
let data = mkData ()
|
||||
try
|
||||
do! WebLogDataTests.``Delete succeeds when the web log exists`` data
|
||||
let! revisions =
|
||||
(data :?> SQLiteData).Conn.customScalar
|
||||
"SELECT (SELECT COUNT(*) FROM page_revision) + (SELECT COUNT(*) FROM post_revision) AS it"
|
||||
[]
|
||||
toCount
|
||||
Expect.equal revisions 0L "All revisions should be deleted"
|
||||
finally dispose data
|
||||
}
|
||||
testTask "succeeds when the web log does not exist" {
|
||||
let data = mkData ()
|
||||
try do! WebLogDataTests.``Delete succeeds when the web log does not exist`` data
|
||||
finally dispose data
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Delete the SQLite database
|
||||
let private environmentCleanUp = test "Clean Up" {
|
||||
File.Delete dbName
|
||||
|
@ -943,5 +1049,6 @@ let all =
|
|||
themeAssetTests
|
||||
uploadTests
|
||||
webLogUserTests
|
||||
webLogTests
|
||||
environmentCleanUp ]
|
||||
|> testSequenced
|
||||
|
|
198
src/MyWebLog.Tests/Data/WebLogDataTests.fs
Normal file
198
src/MyWebLog.Tests/Data/WebLogDataTests.fs
Normal file
|
@ -0,0 +1,198 @@
|
|||
/// <summary>
|
||||
/// Integration tests for <see cref="IWebLogData" /> implementations
|
||||
/// </summary>
|
||||
module WebLogDataTests
|
||||
|
||||
open System
|
||||
open Expecto
|
||||
open MyWebLog
|
||||
open MyWebLog.Data
|
||||
|
||||
/// The ID of the root web log
|
||||
let private rootId = CategoryDataTests.rootId
|
||||
|
||||
let ``Add succeeds`` (data: IData) = task {
|
||||
do! data.WebLog.Add
|
||||
{ Id = WebLogId "new-weblog"
|
||||
Name = "Test Web Log"
|
||||
Slug = "test-web-log"
|
||||
Subtitle = None
|
||||
DefaultPage = ""
|
||||
PostsPerPage = 7
|
||||
ThemeId = ThemeId "default"
|
||||
UrlBase = "https://example.com/new"
|
||||
TimeZone = "America/Los_Angeles"
|
||||
Rss =
|
||||
{ IsFeedEnabled = true
|
||||
FeedName = "my-feed.xml"
|
||||
ItemsInFeed = None
|
||||
IsCategoryEnabled = false
|
||||
IsTagEnabled = false
|
||||
Copyright = Some "go for it"
|
||||
CustomFeeds = [] }
|
||||
AutoHtmx = true
|
||||
Uploads = Disk
|
||||
RedirectRules = [ { From = "/here"; To = "/there"; IsRegex = false } ] }
|
||||
let! webLog = data.WebLog.FindById (WebLogId "new-weblog")
|
||||
Expect.isSome webLog "The web log should have been returned"
|
||||
let it = webLog.Value
|
||||
Expect.equal it.Id (WebLogId "new-weblog") "ID is incorrect"
|
||||
Expect.equal it.Name "Test Web Log" "Name is incorrect"
|
||||
Expect.equal it.Slug "test-web-log" "Slug is incorrect"
|
||||
Expect.isNone it.Subtitle "Subtitle is incorrect"
|
||||
Expect.equal it.DefaultPage "" "Default page is incorrect"
|
||||
Expect.equal it.PostsPerPage 7 "Posts per page is incorrect"
|
||||
Expect.equal it.ThemeId (ThemeId "default") "Theme ID is incorrect"
|
||||
Expect.equal it.UrlBase "https://example.com/new" "URL base is incorrect"
|
||||
Expect.equal it.TimeZone "America/Los_Angeles" "Time zone is incorrect"
|
||||
Expect.isTrue it.AutoHtmx "Auto htmx flag is incorrect"
|
||||
Expect.equal it.Uploads Disk "Upload destination is incorrect"
|
||||
Expect.equal it.RedirectRules [ { From = "/here"; To = "/there"; IsRegex = false } ] "Redirect rules are incorrect"
|
||||
let rss = it.Rss
|
||||
Expect.isTrue rss.IsFeedEnabled "Is feed enabled flag is incorrect"
|
||||
Expect.equal rss.FeedName "my-feed.xml" "Feed name is incorrect"
|
||||
Expect.isNone rss.ItemsInFeed "Items in feed is incorrect"
|
||||
Expect.isFalse rss.IsCategoryEnabled "Is category enabled flag is incorrect"
|
||||
Expect.isFalse rss.IsTagEnabled "Is tag enabled flag is incorrect"
|
||||
Expect.equal rss.Copyright (Some "go for it") "Copyright is incorrect"
|
||||
Expect.isEmpty rss.CustomFeeds "Custom feeds are incorrect"
|
||||
}
|
||||
|
||||
let ``All succeeds`` (data: IData) = task {
|
||||
let! webLogs = data.WebLog.All()
|
||||
Expect.hasLength webLogs 2 "There should have been 2 web logs returned"
|
||||
for webLog in webLogs do
|
||||
Expect.contains [ rootId; WebLogId "new-weblog" ] webLog.Id $"Unexpected web log returned ({webLog.Id})"
|
||||
}
|
||||
|
||||
let ``FindByHost succeeds when a web log is found`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindByHost "http://localhost:8081"
|
||||
Expect.isSome webLog "A web log should have been returned"
|
||||
Expect.equal webLog.Value.Id rootId "The wrong web log was returned"
|
||||
}
|
||||
|
||||
let ``FindByHost succeeds when a web log is not found`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindByHost "https://test.units"
|
||||
Expect.isNone webLog "There should not have been a web log returned"
|
||||
}
|
||||
|
||||
let ``FindById succeeds when a web log is found`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindById rootId
|
||||
Expect.isSome webLog "There should have been a web log returned"
|
||||
let it = webLog.Value
|
||||
Expect.equal it.Id rootId "ID is incorrect"
|
||||
Expect.equal it.Name "Root WebLog" "Name is incorrect"
|
||||
Expect.equal it.Slug "root-weblog" "Slug is incorrect"
|
||||
Expect.equal it.Subtitle (Some "This is the main one") "Subtitle is incorrect"
|
||||
Expect.equal it.DefaultPage "posts" "Default page is incorrect"
|
||||
Expect.equal it.PostsPerPage 9 "Posts per page is incorrect"
|
||||
Expect.equal it.ThemeId (ThemeId "default") "Theme ID is incorrect"
|
||||
Expect.equal it.UrlBase "http://localhost:8081" "URL base is incorrect"
|
||||
Expect.equal it.TimeZone "America/Denver" "Time zone is incorrect"
|
||||
Expect.isTrue it.AutoHtmx "Auto htmx flag is incorrect"
|
||||
Expect.equal it.Uploads Database "Upload destination is incorrect"
|
||||
Expect.isEmpty it.RedirectRules "Redirect rules are incorrect"
|
||||
let rss = it.Rss
|
||||
Expect.isTrue rss.IsFeedEnabled "Is feed enabled flag is incorrect"
|
||||
Expect.equal rss.FeedName "feed" "Feed name is incorrect"
|
||||
Expect.equal rss.ItemsInFeed (Some 7) "Items in feed is incorrect"
|
||||
Expect.isTrue rss.IsCategoryEnabled "Is category enabled flag is incorrect"
|
||||
Expect.isTrue rss.IsTagEnabled "Is tag enabled flag is incorrect"
|
||||
Expect.equal rss.Copyright (Some "CC40-NC-BY") "Copyright is incorrect"
|
||||
Expect.hasLength rss.CustomFeeds 1 "There should be 1 custom feed"
|
||||
Expect.equal rss.CustomFeeds[0].Id (CustomFeedId "isPQ6drbDEydxohQzaiYtQ") "Custom feed ID incorrect"
|
||||
Expect.equal rss.CustomFeeds[0].Source (Tag "podcast") "Custom feed source is incorrect"
|
||||
Expect.equal rss.CustomFeeds[0].Path (Permalink "podcast-feed") "Custom feed path is incorrect"
|
||||
Expect.isSome rss.CustomFeeds[0].Podcast "There should be podcast settings for this custom feed"
|
||||
let pod = rss.CustomFeeds[0].Podcast.Value
|
||||
Expect.equal pod.Title "Root Podcast" "Podcast title is incorrect"
|
||||
Expect.equal pod.ItemsInFeed 23 "Podcast items in feed is incorrect"
|
||||
Expect.equal pod.Summary "All things that happen in the domain root" "Podcast summary is incorrect"
|
||||
Expect.equal pod.DisplayedAuthor "Podcaster Extraordinaire" "Podcast author is incorrect"
|
||||
Expect.equal pod.Email "podcaster@example.com" "Podcast e-mail is incorrect"
|
||||
Expect.equal pod.ImageUrl (Permalink "images/cover-art.png") "Podcast image URL is incorrect"
|
||||
Expect.equal pod.AppleCategory "Fiction" "Podcast Apple category is incorrect"
|
||||
Expect.equal pod.AppleSubcategory (Some "Drama") "Podcast Apple subcategory is incorrect"
|
||||
Expect.equal pod.Explicit No "Podcast explicit rating is incorrect"
|
||||
Expect.equal pod.DefaultMediaType (Some "audio/mpeg") "Podcast default media type is incorrect"
|
||||
Expect.equal pod.MediaBaseUrl (Some "https://media.example.com/root/") "Podcast media base URL is incorrect"
|
||||
Expect.equal pod.PodcastGuid (Some (Guid.Parse "10fd7f79-c719-4e1d-9da7-10405dd4fd96")) "Podcast GUID is incorrect"
|
||||
Expect.equal pod.FundingUrl (Some "https://example.com/support-us") "Podcast funding URL is incorrect"
|
||||
Expect.equal pod.FundingText (Some "Support Our Work") "Podcast funding text is incorrect"
|
||||
Expect.equal pod.Medium (Some Newsletter) "Podcast medium is incorrect"
|
||||
}
|
||||
|
||||
let ``FindById succeeds when a web log is not found`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindById (WebLogId "no-web-log")
|
||||
Expect.isNone webLog "There should not have been a web log returned"
|
||||
}
|
||||
|
||||
let ``UpdateRedirectRules succeeds when the web log exists`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindById (WebLogId "new-weblog")
|
||||
Expect.isSome webLog "The test web log should have been returned"
|
||||
do! data.WebLog.UpdateRedirectRules
|
||||
{ webLog.Value with
|
||||
RedirectRules = { From = "/now"; To = "/later"; IsRegex = false } :: webLog.Value.RedirectRules }
|
||||
let! updated = data.WebLog.FindById (WebLogId "new-weblog")
|
||||
Expect.isSome updated "The updated web log should have been returned"
|
||||
Expect.equal
|
||||
updated.Value.RedirectRules
|
||||
[ { From = "/now"; To = "/later"; IsRegex = false }; { From = "/here"; To = "/there"; IsRegex = false } ]
|
||||
"Redirect rules not updated correctly"
|
||||
}
|
||||
|
||||
let ``UpdateRedirectRules succeeds when the web log does not exist`` (data: IData) = task {
|
||||
do! data.WebLog.UpdateRedirectRules { WebLog.Empty with Id = WebLogId "no-rules" }
|
||||
Expect.isTrue true "This not raising an exception is the test"
|
||||
}
|
||||
|
||||
let ``UpdateRssOptions succeeds when the web log exists`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindById rootId
|
||||
Expect.isSome webLog "The root web log should have been returned"
|
||||
do! data.WebLog.UpdateRssOptions { webLog.Value with Rss = { webLog.Value.Rss with CustomFeeds = [] } }
|
||||
let! updated = data.WebLog.FindById rootId
|
||||
Expect.isSome updated "The updated web log should have been returned"
|
||||
Expect.isEmpty updated.Value.Rss.CustomFeeds "RSS options not updated correctly"
|
||||
}
|
||||
|
||||
let ``UpdateRssOptions succeeds when the web log does not exist`` (data: IData) = task {
|
||||
do! data.WebLog.UpdateRssOptions { WebLog.Empty with Id = WebLogId "rss-less" }
|
||||
Expect.isTrue true "This not raising an exception is the test"
|
||||
}
|
||||
|
||||
let ``UpdateSettings succeeds when the web log exists`` (data: IData) = task {
|
||||
let! webLog = data.WebLog.FindById rootId
|
||||
Expect.isSome webLog "The root web log should have been returned"
|
||||
do! data.WebLog.UpdateSettings { webLog.Value with AutoHtmx = false; Subtitle = None }
|
||||
let! updated = data.WebLog.FindById rootId
|
||||
Expect.isSome updated "The updated web log should have been returned"
|
||||
Expect.isFalse updated.Value.AutoHtmx "Auto htmx flag not updated correctly"
|
||||
Expect.isNone updated.Value.Subtitle "Subtitle not updated correctly"
|
||||
}
|
||||
|
||||
let ``UpdateSettings succeeds when the web log does not exist`` (data: IData) = task {
|
||||
do! data.WebLog.UpdateRedirectRules { WebLog.Empty with Id = WebLogId "no-settings" }
|
||||
let! webLog = data.WebLog.FindById (WebLogId "no-settings")
|
||||
Expect.isNone webLog "Updating settings should not have created a web log"
|
||||
}
|
||||
|
||||
let ``Delete succeeds when the web log exists`` (data: IData) = task {
|
||||
do! data.WebLog.Delete rootId
|
||||
let! cats = data.Category.FindByWebLog rootId
|
||||
Expect.isEmpty cats "There should be no categories remaining"
|
||||
let! pages = data.Page.FindFullByWebLog rootId
|
||||
Expect.isEmpty pages "There should be no pages remaining"
|
||||
let! posts = data.Post.FindFullByWebLog rootId
|
||||
Expect.isEmpty posts "There should be no posts remaining"
|
||||
let! tagMappings = data.TagMap.FindByWebLog rootId
|
||||
Expect.isEmpty tagMappings "There should be no tag mappings remaining"
|
||||
let! uploads = data.Upload.FindByWebLog rootId
|
||||
Expect.isEmpty uploads "There should be no uploads remaining"
|
||||
let! users = data.WebLogUser.FindByWebLog rootId
|
||||
Expect.isEmpty users "There should be no users remaining"
|
||||
}
|
||||
|
||||
let ``Delete succeeds when the web log does not exist`` (data: IData) = task {
|
||||
do! data.WebLog.Delete rootId // already deleted above
|
||||
Expect.isTrue true "This not raising an exception is the test"
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
<Compile Include="Data\ThemeDataTests.fs" />
|
||||
<Compile Include="Data\UploadDataTests.fs" />
|
||||
<Compile Include="Data\WebLogUserDataTests.fs" />
|
||||
<Compile Include="Data\WebLogDataTests.fs" />
|
||||
<Compile Include="Data\RethinkDbDataTests.fs" />
|
||||
<Compile Include="Data\SQLiteDataTests.fs" />
|
||||
<Compile Include="Data\PostgresDataTests.fs" />
|
||||
|
|
Loading…
Reference in New Issue
Block a user