diff --git a/src/MyWebLog.Tests/Data/CategoryDataTests.fs b/src/MyWebLog.Tests/Data/CategoryDataTests.fs
index a148b7e..9368545 100644
--- a/src/MyWebLog.Tests/Data/CategoryDataTests.fs
+++ b/src/MyWebLog.Tests/Data/CategoryDataTests.fs
@@ -10,7 +10,6 @@ let rootId = WebLogId "uSitJEuD3UyzWC9jgOHc8g"
/// The ID of the Favorites category
let favoritesId = CategoryId "S5JflPsJ9EG7gA2LD4m92A"
-/// Tests for the Add method
let ``Add succeeds`` (data: IData) = task {
let category =
{ Category.Empty with Id = CategoryId "added-cat"; WebLogId = WebLogId "test"; Name = "Added"; Slug = "added" }
diff --git a/src/MyWebLog.Tests/Data/PageDataTests.fs b/src/MyWebLog.Tests/Data/PageDataTests.fs
new file mode 100644
index 0000000..3b04430
--- /dev/null
+++ b/src/MyWebLog.Tests/Data/PageDataTests.fs
@@ -0,0 +1,45 @@
+module PageDataTests
+
+open Expecto
+open MyWebLog
+open MyWebLog.Data
+open NodaTime
+
+let ``Add succeeds`` (data: IData) = task {
+ let page =
+ { Id = PageId "added-page"
+ WebLogId = WebLogId "test"
+ AuthorId = WebLogUserId "the-author"
+ Title = "A New Page"
+ Permalink = Permalink "2024/the-page.htm"
+ PublishedOn = Noda.epoch + Duration.FromDays 3
+ UpdatedOn = Noda.epoch + Duration.FromDays 3 + Duration.FromMinutes 2L
+ IsInPageList = true
+ Template = Some "new-page-template"
+ Text = "
A new page
"
+ Metadata = [ { Name = "Meta Item"; Value = "Meta Value" } ]
+ PriorPermalinks = [ Permalink "2024/the-new-page.htm" ]
+ Revisions = [ { AsOf = Noda.epoch + Duration.FromDays 3; Text = Html "A new page
" } ] }
+ do! data.Page.Add page
+ let! stored = data.Page.FindFullById (PageId "added-page") (WebLogId "test")
+ Expect.isSome stored "The page should have been added"
+ let pg = stored.Value
+ Expect.equal pg.Id page.Id "ID not saved properly"
+ Expect.equal pg.WebLogId page.WebLogId "Web log ID not saved properly"
+ Expect.equal pg.AuthorId page.AuthorId "Author ID not saved properly"
+ Expect.equal pg.Title page.Title "Title not saved properly"
+ Expect.equal pg.Permalink page.Permalink "Permalink not saved properly"
+ Expect.equal pg.PublishedOn page.PublishedOn "Published On not saved properly"
+ Expect.equal pg.UpdatedOn page.UpdatedOn "Updated On not saved properly"
+ Expect.equal pg.IsInPageList page.IsInPageList "Is in page list flag not saved properly"
+ Expect.equal pg.Template page.Template "Template not saved properly"
+ Expect.equal pg.Text page.Text "Text not saved properly"
+ Expect.hasLength pg.Metadata 1 "There should have been one meta item properly"
+ Expect.equal pg.Metadata[0].Name page.Metadata[0].Name "Metadata name not saved properly"
+ Expect.equal pg.Metadata[0].Value page.Metadata[0].Value "Metadata value not saved properly"
+ Expect.hasLength pg.PriorPermalinks 1 "There should have been one prior permalink"
+ Expect.equal pg.PriorPermalinks[0] page.PriorPermalinks[0] "Prior permalink not saved properly"
+ Expect.hasLength pg.Revisions 1 "There should have been one revision"
+ Expect.equal pg.Revisions[0].AsOf page.Revisions[0].AsOf "Revision as of not saved properly"
+ Expect.equal pg.Revisions[0].Text page.Revisions[0].Text "Revision text not saved properly"
+}
diff --git a/src/MyWebLog.Tests/Data/PostgresDataTests.fs b/src/MyWebLog.Tests/Data/PostgresDataTests.fs
index 217f475..dc553e5 100644
--- a/src/MyWebLog.Tests/Data/PostgresDataTests.fs
+++ b/src/MyWebLog.Tests/Data/PostgresDataTests.fs
@@ -38,7 +38,7 @@ let environmentSetUp = testTask "creating database" {
do! freshEnvironment ()
}
-/// Integration tests for the Category implementation in SQLite
+/// Integration tests for the Category implementation in PostgreSQL
let categoryTests = testList "Category" [
testTask "Add succeeds" {
do! CategoryDataTests.``Add succeeds`` (mkData ())
@@ -100,6 +100,13 @@ let categoryTests = testList "Category" [
]
]
+/// Integration tests for the Page implementation in PostgreSQL
+let pageTests = testList "Page" [
+ testTask "Add succeeds" {
+ do! PageDataTests.``Add succeeds`` (mkData ())
+ }
+]
+
/// Drop the throwaway PostgreSQL database
let environmentCleanUp = test "Clean Up" {
if db.IsSome then db.Value.Dispose()
@@ -110,5 +117,6 @@ let all =
testList "PostgresData"
[ environmentSetUp
categoryTests
+ pageTests
environmentCleanUp ]
|> testSequenced
diff --git a/src/MyWebLog.Tests/Data/SQLiteDataTests.fs b/src/MyWebLog.Tests/Data/SQLiteDataTests.fs
index f010601..2f06919 100644
--- a/src/MyWebLog.Tests/Data/SQLiteDataTests.fs
+++ b/src/MyWebLog.Tests/Data/SQLiteDataTests.fs
@@ -141,6 +141,14 @@ let categoryTests = testList "Category" [
]
]
+/// Integration tests for the Page implementation in SQLite
+let pageTests = testList "Page" [
+ testTask "Add succeeds" {
+ let data = mkData ()
+ try do! PageDataTests.``Add succeeds`` data
+ finally dispose data
+ }
+]
/// Delete the SQLite database
let environmentCleanUp = test "Clean Up" {
@@ -153,5 +161,6 @@ let all =
testList "SQLiteData"
[ environmentSetUp
categoryTests
+ pageTests
environmentCleanUp ]
|> testSequenced
diff --git a/src/MyWebLog.Tests/MyWebLog.Tests.fsproj b/src/MyWebLog.Tests/MyWebLog.Tests.fsproj
index 0d58c9e..2066418 100644
--- a/src/MyWebLog.Tests/MyWebLog.Tests.fsproj
+++ b/src/MyWebLog.Tests/MyWebLog.Tests.fsproj
@@ -11,6 +11,7 @@
+