Add tests (#60)

This commit is contained in:
Patrick Stevens
2023-08-06 21:23:21 +01:00
committed by GitHub
parent 6f1fbeb6ee
commit 3a975d7f28
11 changed files with 428 additions and 27 deletions

View File

@@ -61,16 +61,7 @@ module Client =
member _.AdminCreateUser createUserOption =
async {
let! () = server.PostAndAsyncReply (fun reply -> AddUser (createUserOption, reply))
let result = Gitea.User ()
result.Email <- createUserOption.Email
result.Restricted <- createUserOption.Restricted
// TODO: what is this username used for anyway
// result.LoginName <- createUserOption.Username
result.Visibility <- createUserOption.Visibility
result.Created <- createUserOption.CreatedAt
result.FullName <- createUserOption.FullName
result.LoginName <- createUserOption.LoginName
return result
return Operations.createdUser createUserOption
}
|> Async.StartAsTask

View File

@@ -4,27 +4,23 @@ open System
open System.Threading.Tasks
open Gitea.Declarative
type BranchName = | BranchName of string
module Types =
type BranchProtectionRule =
{
RequiredChecks : string Set
}
type BranchName = | BranchName of string
type NativeRepo =
{
BranchProtectionRules : (BranchName * BranchProtectionRule) list
}
type BranchProtectionRule =
{
RequiredChecks : string Set
}
type Repo =
| GitHubMirror of Uri
| NativeRepo of NativeRepo
type NativeRepo =
{
BranchProtectionRules : (BranchName * BranchProtectionRule) list
}
type GiteaState =
{
Users : User Set
Repositories : Map<User * RepoName, Repo>
}
type Repo =
| GitHubMirror of Uri
| NativeRepo of NativeRepo
/// Allows us to use handy record-updating syntax.
/// (I have a considerable dislike of Moq and friends.)

View File

@@ -8,6 +8,7 @@
<ItemGroup>
<Compile Include="Domain.fs" />
<Compile Include="Server.fs" />
<Compile Include="Client.fs" />
</ItemGroup>

18
Gitea.InMemory/Server.fs Normal file
View File

@@ -0,0 +1,18 @@
namespace Gitea.InMemory
open Gitea.Declarative
[<RequireQualifiedAccess>]
module Operations =
let createdUser (createUserOption : Gitea.CreateUserOption) : Gitea.User =
let result = Gitea.User ()
result.Email <- createUserOption.Email
result.Restricted <- createUserOption.Restricted
// TODO: what is this username used for anyway
// result.LoginName <- createUserOption.Username
result.Visibility <- createUserOption.Visibility
result.Created <- createUserOption.CreatedAt
result.FullName <- createUserOption.FullName
result.LoginName <- createUserOption.LoginName
result