diff --git a/src/ARCValidationPackages/Domain.fs b/src/ARCValidationPackages/Domain.fs
index 12b1273..ca3ad96 100644
--- a/src/ARCValidationPackages/Domain.fs
+++ b/src/ARCValidationPackages/Domain.fs
@@ -4,24 +4,95 @@ open System.IO
open System.Text.Json
open System.Text.Json.Serialization
-// must be a class to be deserializable with YamlDotNet
+
+// must be classes to be deserializable with YamlDotNet
+
+///
+/// Represents the author of a validation package
+///
+type Author() =
+ // mandatory fields
+ member val FullName = "" with get,set
+ member val Email = "" with get,set
+ // optional fields
+ member val Affiliation = "" with get,set
+ member val AffiliationLink = "" with get,set
+
+ override this.GetHashCode() = hash (this.FullName, this.Email, this.Affiliation, this.AffiliationLink)
+
+ override this.Equals(other) =
+ match other with
+ | :? Author as a ->
+ (this.FullName, this.Email, this.Affiliation, this.AffiliationLink) = (a.FullName, a.Email, a.Affiliation, a.AffiliationLink)
+ | _ -> false
+
+ static member create(
+ fullName: string,
+ email: string,
+ ?Affiliation: string,
+ ?AffiliationLink: string
+ ) =
+ let tmp = Author()
+ tmp.FullName <- fullName
+ tmp.Email <- email
+ Affiliation |> Option.iter (fun x -> tmp.Affiliation <- x)
+ AffiliationLink |> Option.iter (fun x -> tmp.AffiliationLink <- x)
+ tmp
+
+
///
/// Represents the metadata of a validation package, e.g. version, name and description.
///
type ValidationPackageMetadata() =
+ // mandatory fields
member val Name = "" with get,set
member val Description = "" with get,set
member val MajorVersion = 0 with get,set
member val MinorVersion = 0 with get,set
member val PatchVersion = 0 with get,set
+ // optional fields
+ member val Publish = false with get,set
+ member val Authors: Author [] = Array.empty with get,set
+ member val Tags: string [] = Array.empty with get,set
+ member val ReleaseNotes = "" with get,set
override this.GetHashCode() =
- hash (this.Name, this.Description, this.MajorVersion, this.MinorVersion, this.PatchVersion)
+ hash (
+ this.Name,
+ this.Description,
+ this.MajorVersion,
+ this.MinorVersion,
+ this.PatchVersion,
+ this.Publish,
+ this.Authors,
+ this.Tags,
+ this.ReleaseNotes
+ )
override this.Equals(other) =
match other with
| :? ValidationPackageMetadata as vpm ->
- (this.Name, this.Description, this.MajorVersion, this.MinorVersion, this.PatchVersion) = (vpm.Name, vpm.Description, vpm.MajorVersion, vpm.MinorVersion, vpm.PatchVersion)
+ (
+ this.Name,
+ this.Description,
+ this.MajorVersion,
+ this.MinorVersion,
+ this.PatchVersion,
+ this.Publish,
+ this.Authors,
+ this.Tags,
+ this.ReleaseNotes
+ ) = (
+ vpm.Name,
+ vpm.Description,
+ vpm.MajorVersion,
+ vpm.MinorVersion,
+ vpm.PatchVersion,
+ vpm.Publish,
+ vpm.Authors,
+ vpm.Tags,
+ vpm.ReleaseNotes
+ )
| _ -> false
static member create (
@@ -29,7 +100,11 @@ type ValidationPackageMetadata() =
description: string,
majorVersion: int,
minorVersion: int,
- patchVersion: int
+ patchVersion: int,
+ ?Publish: bool,
+ ?Authors: Author [],
+ ?Tags: string [],
+ ?ReleaseNotes
) =
let tmp = ValidationPackageMetadata()
tmp.Name <- name
@@ -37,6 +112,11 @@ type ValidationPackageMetadata() =
tmp.MajorVersion <- majorVersion
tmp.MinorVersion <- minorVersion
tmp.PatchVersion <- patchVersion
+ Publish |> Option.iter (fun x -> tmp.Publish <- x)
+ Authors |> Option.iter (fun x -> tmp.Authors <- x)
+ Tags |> Option.iter (fun x -> tmp.Tags <- x)
+ ReleaseNotes |> Option.iter (fun x -> tmp.ReleaseNotes <- x)
+
tmp
static member getSemanticVersionString(m: ValidationPackageMetadata) = $"{m.MajorVersion}.{m.MinorVersion}.{m.PatchVersion}";
diff --git a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs
index 412c7aa..471672a 100644
--- a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs
+++ b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs
@@ -10,7 +10,7 @@ open TestUtils
let testDate1 = System.DateTimeOffset.ParseExact("2023-08-15 10:00:00 +02:00", "yyyy-MM-dd HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture)
let testDate2 = System.DateTimeOffset.ParseExact("2023-08-15 11:00:00 +02:00", "yyyy-MM-dd HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture)
-
+let testDate3 = System.DateTimeOffset.ParseExact("2024-02-22 09:00:17 +01:00", "yyyy-MM-dd HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture)
let testPackageIndex =
[|
@@ -29,6 +29,7 @@ Description: this package is here for testing purposes only.
MajorVersion: 1
MinorVersion: 0
PatchVersion: 0
+Publish: true
---
*)
@@ -51,6 +52,41 @@ let testValidationPackage2 =
ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", 1, 0, 0)
)
+let testValidationPackage3FullMetadata =
+ ARCValidationPackage.create(
+ "test@3.0.0.fsx",
+ testDate3,
+ (Path.Combine(expected_package_cache_folder_path, "test@3.0.0.fsx").Replace("\\","/")),
+ ValidationPackageMetadata.create(
+ "test",
+ "this package is here for testing purposes only.",
+ 1,
+ 0,
+ 0,
+ Publish = true,
+ Authors = [|
+ Author.create(
+ fullName = "John Doe",
+ email = "j@d.com",
+ Affiliation = "University of Nowhere",
+ AffiliationLink = "https://nowhere.edu"
+ )
+ Author.create(
+ fullName = "Jane Doe",
+ email = "jj@d.com",
+ Affiliation = "University of Somewhere",
+ AffiliationLink = "https://somewhere.edu"
+ )
+ |],
+ Tags = [|
+ "validation"
+ "my-package"
+ "thing"
+ |],
+ ReleaseNotes = "add authors and tags for further testing"
+ )
+ )
+
let testPackageCache1 = PackageCache([testValidationPackage1])
let testPackageCache2 = PackageCache([testValidationPackage2])
diff --git a/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs b/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs
index bd04e74..9c4b918 100644
--- a/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs
+++ b/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs
@@ -53,7 +53,7 @@ let ``ValidateCommand CLI Tests`` =
(get_gh_api_token())
) [
"Package script exists after running package install test" ,
- fun tool args proc -> Expect.isTrue (File.Exists(Path.Combine(expected_package_cache_folder_path, "test@2.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args )
+ fun tool args proc -> Expect.isTrue (File.Exists(Path.Combine(expected_package_cache_folder_path, "test@3.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args )
]
yield!
testFixture (Fixtures.withToolExecution
@@ -67,7 +67,7 @@ let ``ValidateCommand CLI Tests`` =
"Console output does not indicate that package is not installed" ,
fun tool args proc -> Expect.isFalse (proc.Result.Output.Contains("Package test not installed. You can run run arc-validate package install ")) (ErrorMessage.withProcessDiagnostics "incorrect console output" proc tool args )
"Console Output is correct" ,
- fun tool args proc -> Expect.isTrue (proc.Result.Output.Contains("Hello, world!")) (ErrorMessage.withProcessDiagnostics "incorrect console output" proc tool args )
+ fun tool args proc -> Expect.isTrue (proc.Result.Output.Contains("If you can read this in your console, you successfully executed test package v3.0.0!")) (ErrorMessage.withProcessDiagnostics "incorrect console output" proc tool args )
]
])
diff --git a/tests/arc-validate.Tests/ReferenceObjects.fs b/tests/arc-validate.Tests/ReferenceObjects.fs
index 6704bcc..d2caa60 100644
--- a/tests/arc-validate.Tests/ReferenceObjects.fs
+++ b/tests/arc-validate.Tests/ReferenceObjects.fs
@@ -14,6 +14,7 @@ Description: this package is here for testing purposes only.
MajorVersion: 1
MinorVersion: 0
PatchVersion: 0
+Publish: true
---
*)
@@ -26,6 +27,7 @@ Name: test
MajorVersion: 2
MinorVersion: 0
PatchVersion: 0
+Publish: true
Description: this package is here for testing purposes only.
Authors:
- FullName: John Doe