Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hook endpoint to Index model #48

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/AVPRClient/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ this AVPRClient.ValidationPackage validationPackage
Microsoft.FSharp.Core.FSharpOption<bool>.None,
validationPackage.Authors.AsIndexType(),
validationPackage.Tags.AsIndexType(),
validationPackage.ReleaseNotes
validationPackage.ReleaseNotes,
Microsoft.FSharp.Core.FSharpOption<string>.None
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AVPRIndex/AVPRIndex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md"))</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.1.0</PackageVersion>
<PackageVersion>0.1.1</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 10 additions & 4 deletions src/AVPRIndex/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module Domain =
member val Authors: Author [] = Array.empty<Author> with get,set
member val Tags: OntologyAnnotation [] = Array.empty<OntologyAnnotation> with get,set
member val ReleaseNotes = "" with get,set
member val CQCHookEndpoint = "" with get,set

override this.GetHashCode() =
hash (
Expand All @@ -118,7 +119,8 @@ module Domain =
this.Publish,
this.Authors,
this.Tags,
this.ReleaseNotes
this.ReleaseNotes,
this.CQCHookEndpoint
)

override this.Equals(other) =
Expand All @@ -134,7 +136,8 @@ module Domain =
this.Publish,
this.Authors,
this.Tags,
this.ReleaseNotes
this.ReleaseNotes,
this.CQCHookEndpoint
) = (
vpm.Name,
vpm.Summary,
Expand All @@ -145,7 +148,8 @@ module Domain =
vpm.Publish,
vpm.Authors,
vpm.Tags,
vpm.ReleaseNotes
vpm.ReleaseNotes,
vpm.CQCHookEndpoint
)
| _ -> false

Expand All @@ -159,7 +163,8 @@ module Domain =
?Publish: bool,
?Authors: Author [],
?Tags: OntologyAnnotation [],
?ReleaseNotes
?ReleaseNotes,
?CQCHookEndpoint
) =
let tmp = ValidationPackageMetadata(
Name = name,
Expand All @@ -174,6 +179,7 @@ module Domain =
Authors |> Option.iter (fun x -> tmp.Authors <- x)
Tags |> Option.iter (fun x -> tmp.Tags <- x)
ReleaseNotes |> Option.iter (fun x -> tmp.ReleaseNotes <- x)
CQCHookEndpoint |> Option.iter (fun x -> tmp.CQCHookEndpoint <- x)

tmp

Expand Down
4 changes: 4 additions & 0 deletions src/AVPRIndex/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.1.1

Add `CQCHookEndpoint` field to `ValidationPackageMetadata`

## v0.1.0

Add support for in-package frontmatter bindings. Enables re-use of the frontmatter inside the package code
Expand Down
44 changes: 44 additions & 0 deletions tests/IndexTests/DomainTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,47 @@ module OntologyAnnotation =
TermAccessionNumber = "TAN"
)
Assert.Equivalent(OntologyAnnotation.allFields, actual)

module ValidationPackageMetadata =

[<Fact>]
let ``create function for mandatory fields``() =
let actual = ValidationPackageMetadata.create(
name = "name",
summary = "summary" ,
description = "description" ,
majorVersion = 1,
minorVersion = 0,
patchVersion = 0
)
Assert.Equivalent(ValidationPackageMetadata.mandatoryFields, actual)

[<Fact>]
let ``create function for all fields``() =
let actual = ValidationPackageMetadata.create(
name = "name",
summary = "summary" ,
description = "description" ,
majorVersion = 1,
minorVersion = 0,
patchVersion = 0,
Publish = true,
Authors = [|
Author.create(
fullName = "test",
Email = "[email protected]",
Affiliation = "testaffiliation",
AffiliationLink = "test.com"
)
|],
Tags = [|
OntologyAnnotation.create(
name = "test",
TermSourceREF = "REF",
TermAccessionNumber = "TAN"
)
|],
ReleaseNotes = "releasenotes",
CQCHookEndpoint = "hookendpoint"
)
Assert.Equivalent(ValidationPackageMetadata.allFields, actual)
32 changes: 31 additions & 1 deletion tests/IndexTests/ReferenceObjects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ module OntologyAnnotation =
TermAccessionNumber = "TAN"
)

module ValidationPackageMetadata =

let mandatoryFields = ValidationPackageMetadata(
Name = "name",
Summary = "summary" ,
Description = "description" ,
MajorVersion = 1,
MinorVersion = 0,
PatchVersion = 0
)

let allFields = ValidationPackageMetadata(
Name = "name",
Summary = "summary" ,
Description = "description" ,
MajorVersion = 1,
MinorVersion = 0,
PatchVersion = 0,
Publish = true,
Authors = [|Author.allFields|],
Tags = [|OntologyAnnotation.allFields|],
ReleaseNotes = "releasenotes",
CQCHookEndpoint = "hookendpoint"
)

module Frontmatter =

module Comment =
Expand Down Expand Up @@ -89,6 +114,7 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
---
*)""" .ReplaceLineEndings("\n")

Expand Down Expand Up @@ -121,6 +147,7 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
""" .ReplaceLineEndings("\n")

let invalidStartFrontmatter = """(
Expand Down Expand Up @@ -232,6 +259,7 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
---
*)\"\"\"" .ReplaceLineEndings("\n")

Expand Down Expand Up @@ -264,6 +292,7 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
""" .ReplaceLineEndings("\n")

let invalidStartFrontmatter = "let [<Literal>]PACKAGE_METADATA = \"\"\"
Expand Down Expand Up @@ -365,7 +394,8 @@ It does it very fast, it does it very swell.
ReleaseNotes = """- initial release
- does the thing
- does it well
""".ReplaceLineEndings("\n")
""".ReplaceLineEndings("\n"),
CQCHookEndpoint = "https://hook.com"
)

let invalidMissingMandatoryFrontmatter =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
---
*)"""
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ ReleaseNotes: |
- initial release
- does the thing
- does it well
CQCHookEndpoint: https://hook.com
---
*)
Loading