mirror of
https://github.com/Smaug123/gitea-repo-config
synced 2025-10-09 17:38:38 +00:00
First test (#59)
This commit is contained in:
43
Gitea.Declarative.Test/TestUser.fs
Normal file
43
Gitea.Declarative.Test/TestUser.fs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace Gitea.Declarative.Test
|
||||
|
||||
open System
|
||||
open System.Threading.Tasks
|
||||
open FsCheck
|
||||
open Gitea.InMemory
|
||||
open Gitea.Declarative
|
||||
open FsUnitTyped
|
||||
open Microsoft.Extensions.Logging.Abstractions
|
||||
open NUnit.Framework
|
||||
|
||||
[<TestFixture>]
|
||||
[<RequireQualifiedAccess>]
|
||||
module TestUser =
|
||||
|
||||
[<Test>]
|
||||
let ``We set MustChangePassword on creating a user`` () =
|
||||
Arb.register<CustomArb> () |> ignore
|
||||
|
||||
let property (desiredUser : UserInfo) =
|
||||
let result = TaskCompletionSource<bool option> ()
|
||||
|
||||
let client =
|
||||
{ GiteaClientMock.Unimplemented with
|
||||
AdminCreateUser =
|
||||
fun options ->
|
||||
async {
|
||||
result.SetResult options.MustChangePassword
|
||||
return null
|
||||
}
|
||||
|> Async.StartAsTask
|
||||
}
|
||||
|
||||
[ User "username", AlignmentError.DoesNotExist desiredUser ]
|
||||
|> Map.ofList
|
||||
|> Gitea.reconcileUserErrors NullLogger.Instance (fun _ -> failwith "do not ask for user input") client
|
||||
|> Async.RunSynchronously
|
||||
|
||||
result.Task.Wait (TimeSpan.FromSeconds 10.0) |> shouldEqual true
|
||||
|
||||
result.Task.Result |> shouldEqual (Some true)
|
||||
|
||||
Check.QuickThrowOnFailure property
|
Reference in New Issue
Block a user