From d7c8cae0c785c1849e2ba4a62e59d2fc537ef774 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Wed, 5 Jun 2024 21:43:03 -0400 Subject: [PATCH] Add tests for alpha BT values - Update deps - Update release notes for v3.1 --- src/Common/BitBadger.Documents.Common.fsproj | 3 ++- src/Directory.Build.props | 1 + src/Postgres/BitBadger.Documents.Postgres.fsproj | 1 + src/Sqlite/BitBadger.Documents.Sqlite.fsproj | 3 ++- .../BitBadger.Documents.Tests.CSharp.csproj | 2 +- src/Tests.CSharp/PostgresCSharpTests.cs | 10 +++++++++- src/Tests.CSharp/SqliteCSharpTests.cs | 10 +++++++++- src/Tests/BitBadger.Documents.Tests.fsproj | 3 ++- src/Tests/PostgresTests.fs | 9 ++++++++- src/Tests/SqliteTests.fs | 9 ++++++++- 10 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/Common/BitBadger.Documents.Common.fsproj b/src/Common/BitBadger.Documents.Common.fsproj index bded7fe..6e91b44 100644 --- a/src/Common/BitBadger.Documents.Common.fsproj +++ b/src/Common/BitBadger.Documents.Common.fsproj @@ -13,7 +13,8 @@ - + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 274bd5c..ea70aa3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -6,6 +6,7 @@ 3.1.0.0 3.1.0.0 3.1.0 + Add BT (between) operator; drop .NET 7 support danieljsummers Bit Badger Solutions README.md diff --git a/src/Postgres/BitBadger.Documents.Postgres.fsproj b/src/Postgres/BitBadger.Documents.Postgres.fsproj index a8eb158..316d2ae 100644 --- a/src/Postgres/BitBadger.Documents.Postgres.fsproj +++ b/src/Postgres/BitBadger.Documents.Postgres.fsproj @@ -15,6 +15,7 @@ + diff --git a/src/Sqlite/BitBadger.Documents.Sqlite.fsproj b/src/Sqlite/BitBadger.Documents.Sqlite.fsproj index b6009bb..14a006d 100644 --- a/src/Sqlite/BitBadger.Documents.Sqlite.fsproj +++ b/src/Sqlite/BitBadger.Documents.Sqlite.fsproj @@ -14,7 +14,8 @@ - + + diff --git a/src/Tests.CSharp/BitBadger.Documents.Tests.CSharp.csproj b/src/Tests.CSharp/BitBadger.Documents.Tests.CSharp.csproj index 489d298..951b6d7 100644 --- a/src/Tests.CSharp/BitBadger.Documents.Tests.CSharp.csproj +++ b/src/Tests.CSharp/BitBadger.Documents.Tests.CSharp.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Tests.CSharp/PostgresCSharpTests.cs b/src/Tests.CSharp/PostgresCSharpTests.cs index 8f892a8..9ddd720 100644 --- a/src/Tests.CSharp/PostgresCSharpTests.cs +++ b/src/Tests.CSharp/PostgresCSharpTests.cs @@ -549,7 +549,7 @@ public static class PostgresCSharpTests var theCount = await Count.All(PostgresDb.TableName); Expect.equal(theCount, 5, "There should have been 5 matching documents"); }), - TestCase("ByField succeeds", async () => + TestCase("ByField succeeds for numeric range", async () => { await using var db = PostgresDb.BuildDb(); await LoadDocs(); @@ -557,6 +557,14 @@ public static class PostgresCSharpTests var theCount = await Count.ByField(PostgresDb.TableName, Field.BT("NumValue", 10, 20)); Expect.equal(theCount, 3, "There should have been 3 matching documents"); }), + TestCase("ByField succeeds for non-numeric range", async () => + { + await using var db = PostgresDb.BuildDb(); + await LoadDocs(); + + var theCount = await Count.ByField(PostgresDb.TableName, Field.BT("Value", "aardvark", "apple")); + Expect.equal(theCount, 1, "There should have been 1 matching document"); + }), TestCase("ByContains succeeds", async () => { await using var db = PostgresDb.BuildDb(); diff --git a/src/Tests.CSharp/SqliteCSharpTests.cs b/src/Tests.CSharp/SqliteCSharpTests.cs index 5d17876..6f38664 100644 --- a/src/Tests.CSharp/SqliteCSharpTests.cs +++ b/src/Tests.CSharp/SqliteCSharpTests.cs @@ -399,13 +399,21 @@ public static class SqliteCSharpTests var theCount = await Count.All(SqliteDb.TableName); Expect.equal(theCount, 5L, "There should have been 5 matching documents"); }), - TestCase("ByField succeeds", async () => + TestCase("ByField succeeds for numeric range", async () => { await using var db = await SqliteDb.BuildDb(); await LoadDocs(); var theCount = await Count.ByField(SqliteDb.TableName, Field.BT("NumValue", 10, 20)); Expect.equal(theCount, 3L, "There should have been 3 matching documents"); + }), + TestCase("ByField succeeds for non-numeric range", async () => + { + await using var db = await SqliteDb.BuildDb(); + await LoadDocs(); + + var theCount = await Count.ByField(SqliteDb.TableName, Field.BT("Value", "aardvark", "apple")); + Expect.equal(theCount, 1L, "There should have been 1 matching document"); }) }), TestList("Exists", new[] diff --git a/src/Tests/BitBadger.Documents.Tests.fsproj b/src/Tests/BitBadger.Documents.Tests.fsproj index 9e753ad..90c8b65 100644 --- a/src/Tests/BitBadger.Documents.Tests.fsproj +++ b/src/Tests/BitBadger.Documents.Tests.fsproj @@ -15,7 +15,8 @@ - + + diff --git a/src/Tests/PostgresTests.fs b/src/Tests/PostgresTests.fs index 76405a1..6849b8b 100644 --- a/src/Tests/PostgresTests.fs +++ b/src/Tests/PostgresTests.fs @@ -488,13 +488,20 @@ let integrationTests = let! theCount = Count.all PostgresDb.TableName Expect.equal theCount 5 "There should have been 5 matching documents" } - testTask "byField succeeds" { + testTask "byField succeeds for numeric range" { use db = PostgresDb.BuildDb() do! loadDocs () let! theCount = Count.byField PostgresDb.TableName (Field.BT "NumValue" 10 20) Expect.equal theCount 3 "There should have been 3 matching documents" } + testTask "byField succeeds for non-numeric range" { + use db = PostgresDb.BuildDb() + do! loadDocs () + + let! theCount = Count.byField PostgresDb.TableName (Field.BT "Value" "aardvark" "apple") + Expect.equal theCount 1 "There should have been 1 matching document" + } testTask "byContains succeeds" { use db = PostgresDb.BuildDb() do! loadDocs () diff --git a/src/Tests/SqliteTests.fs b/src/Tests/SqliteTests.fs index c32ba1b..6d97893 100644 --- a/src/Tests/SqliteTests.fs +++ b/src/Tests/SqliteTests.fs @@ -381,13 +381,20 @@ let integrationTests = let! theCount = Count.all SqliteDb.TableName Expect.equal theCount 5L "There should have been 5 matching documents" } - testTask "byField succeeds" { + testTask "byField succeeds for a numeric range" { use! db = SqliteDb.BuildDb() do! loadDocs () let! theCount = Count.byField SqliteDb.TableName (Field.BT "NumValue" 10 20) Expect.equal theCount 3L "There should have been 3 matching documents" } + testTask "byField succeeds for a non-numeric range" { + use! db = SqliteDb.BuildDb() + do! loadDocs () + + let! theCount = Count.byField SqliteDb.TableName (Field.BT "Value" "aardvark" "apple") + Expect.equal theCount 1L "There should have been 1 matching document" + } ] testList "Exists" [ testList "byId" [