Skip to content

Commit

Permalink
Fix tests and annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelMunoz committed Oct 1, 2023
1 parent a5118e7 commit 902a2d3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/Migrondi.Core/Database.fs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ type DatabaseService =
[<Optional>] ?cancellationToken: CancellationToken ->
Task<MigrationRecord IReadOnlyList>


[<RequireQualifiedAccess>]
module Queries =
let createTable driver tableName =
Expand Down Expand Up @@ -181,7 +182,7 @@ CREATE TABLE dbo.%s{tableName}(
);
GO"""

module MigrationsImpl =
module internal MigrationsImpl =

let inline private (=>) (a: string) b = a, box b

Expand Down
5 changes: 5 additions & 0 deletions src/Migrondi.Core/Database.fsi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Migrondi.Core.Database

open System.Collections.Generic
open System.Data
open System.Runtime.InteropServices
open System.Threading
open System.Threading.Tasks
Expand Down Expand Up @@ -135,6 +136,10 @@ type DatabaseService =
migrations: Migration seq * [<Optional>] ?cancellationToken: CancellationToken ->
Task<MigrationRecord IReadOnlyList>

module internal MigrationsImpl =

val getConnection: connectionString: string * driver: MigrondiDriver -> IDbConnection

[<Class>]
type DatabaseServiceFactory =
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Migrondi.Core/Migrondi.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
</Summary>
<IsPackable>True</IsPackable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<InternalsVisibleTo>Migrondi.Tests</InternalsVisibleTo>
</PropertyGroup>
<ItemGroup>
<InternalsVisibleTo Include="Migrondi.Tests" />
</ItemGroup>
<ItemGroup>
<Compile Include="Library.fsi" />
<Compile Include="Library.fs" />
Expand Down
12 changes: 5 additions & 7 deletions src/Migrondi.Tests/Database.Async.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open System.Threading.Tasks

open Microsoft.VisualStudio.TestTools.UnitTesting

open Microsoft.Extensions.Logging

open RepoDb

open FsToolkit.ErrorHandling
Expand All @@ -14,21 +16,17 @@ open Migrondi.Core.Database

open Migrondi.Tests.Database

open Serilog
open Serilog.Extensions.Logging


[<TestClass>]
type DatabaseAsyncTests() =

let dbName = Guid.NewGuid()
let config = DatabaseData.getConfig dbName

let baseLogger =
LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().CreateLogger()
let loggerFactory =
LoggerFactory.Create(fun builder -> builder.SetMinimumLevel(LogLevel.Debug).AddSimpleConsole() |> ignore)

let loggerFactory = new SerilogLoggerFactory(baseLogger)
let logger = loggerFactory.CreateLogger("Migrondi:Tests.Database.Async")
let logger = loggerFactory.CreateLogger("Migrondi:Tests.Database")

let databaseEnv =
DatabaseServiceFactory.GetInstance(logger, DatabaseData.getConfig dbName)
Expand Down
9 changes: 4 additions & 5 deletions src/Migrondi.Tests/Database.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ open RepoDb

open FsToolkit.ErrorHandling

open Microsoft.Extensions.Logging

open Migrondi.Core
open Migrondi.Core.Database

open Serilog
open Serilog.Extensions.Logging

module DatabaseData =
open System.Data
Expand Down Expand Up @@ -91,10 +91,9 @@ type DatabaseTests() =
let dbName = Guid.NewGuid()
let config = DatabaseData.getConfig dbName

let baseLogger =
LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().CreateLogger()
let loggerFactory =
LoggerFactory.Create(fun builder -> builder.SetMinimumLevel(LogLevel.Debug).AddSimpleConsole() |> ignore)

let loggerFactory = new SerilogLoggerFactory(baseLogger)
let logger = loggerFactory.CreateLogger("Migrondi:Tests.Database")

let databaseEnv =
Expand Down
10 changes: 8 additions & 2 deletions src/Migrondi.Tests/FileSystem.fs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module Migrondi.Tests.FileSystem


open System
open System.IO
open System.Threading.Tasks
open Microsoft.VisualStudio.TestTools.UnitTesting

open FSharp.UMX

open Microsoft.Extensions.Logging

open Migrondi.Core
open Migrondi.Core.Serialization
open Migrondi.Core.FileSystem
open Migrondi.Core.FileSystem.Units

open FsToolkit.ErrorHandling

Expand Down Expand Up @@ -77,9 +77,15 @@ type FileSystemTests() =

let serializer = SerializerServiceFactory.GetInstance()

let loggerFactory =
LoggerFactory.Create(fun builder -> builder.SetMinimumLevel(LogLevel.Debug).AddSimpleConsole() |> ignore)

let logger = loggerFactory.CreateLogger("Migrondi:Tests.Database")

let fileSystem =
FileSystemServiceFactory.GetInstance(
serializer,
logger,
baseUri,
Uri("fs-migrations/", UriKind.Relative)
)
Expand Down
2 changes: 1 addition & 1 deletion src/Migrondi.Tests/Migrondi.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Migrondi.Core\Migrondi.Core.fsproj" />
Expand Down

0 comments on commit 902a2d3

Please sign in to comment.