Skip to content

Commit

Permalink
update upstream dependencies, add tests for a package with CQCHookEnd…
Browse files Browse the repository at this point in the history
…point
  • Loading branch information
kMutagene committed Jun 19, 2024
1 parent 6322d70 commit 9d19617
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/ARCExpect/ARCExpect.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
<PackageReference Include="OBO.NET" Version="[0.4.2]" />
<PackageReference Include="AnyBadge.NET" Version="[2.0.0]" />
<PackageReference Include="FSharp.SystemTextJson" Version="[1.3.13]" />
<PackageReference Include="AVPRIndex" Version="[0.1.1]" />
<PackageReference Include="AVPRIndex" Version="[0.1.3]" />
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions src/ARCExpect/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.0.1 - (Released 2024-04-30)

Update pinned dependencies

### 3.0.0 - (Released 2024-04-30)

Remove separate `CQCHookEndpoint` because it is now directly contained in package metadata.
Expand Down
4 changes: 2 additions & 2 deletions src/ARCValidationPackages/ARCValidationPackages.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<ItemGroup>
<PackageReference Include="Fake.DotNet.Cli" Version="[6.0.0]" />
<PackageReference Include="FsHttp" Version="[14.5.0]" />
<PackageReference Include="AVPRIndex" Version="[0.1.1]" />
<PackageReference Include="AVPRClient" Version="[0.0.5]" />
<PackageReference Include="AVPRIndex" Version="[0.1.3]" />
<PackageReference Include="AVPRClient" Version="[0.0.9]" />
</ItemGroup>

</Project>
6 changes: 5 additions & 1 deletion src/ARCValidationPackages/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### 4.0.0 - (Released 2024-04-30)
### 4.0.1 - (Released 2024-04-30)

Update pinned dependencies

### 4.0.0 - (Released 2024-04-30)

Update to AVPRIndex v0.1.1 and AVPRClient v0.0.5

Expand Down
35 changes: 21 additions & 14 deletions tests/ARCValidationPackages.Tests/AVPRAPITests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,34 @@ let token = get_gh_api_token()
[<Tests>]
let ``AVPRAPI tests`` =
testList "AVPR API tests" [
test "getRepositoryContent returns correct content" {
let vp = AVPR.api.GetPackageByNameAndVersion "test" "3.0.0"
let script =
vp.PackageContent
|> Encoding.UTF8.GetString
Expect.equal
(script.ReplaceLineEndings())
ReferenceObjects.testScriptContentAVPR
$"repository content was not correct{System.Environment.NewLine}{script}"
}
test "getPackageIndex contains test script" {
testList "GetPackageByNameAndVersion" [
test "test_3_0_0" {
let vp = AVPR.api.GetPackageByNameAndVersion "test" "3.0.0"
Expect.AVPRClient.validationPackageEqual vp ReferenceObjects.AVPRClientDomain.ValidationPackage.testPackage_3_0_0
}
test "test_5_0_0 - CQCHookEndpoint addition" {
let vp = AVPR.api.GetPackageByNameAndVersion "test" "5.0.0"
let script =
vp.PackageContent
|> Encoding.UTF8.GetString
Expect.equal
(script.ReplaceLineEndings("\n"))
ReferenceObjects.testScriptContentAVPR_test_5_0_0
$"repository content was not correct{System.Environment.NewLine}{script}"
}

]
test "GetAllPackages contains a test package" {
let indexedPackages = AVPR.api.GetAllPackages()
Expect.isTrue (indexedPackages |> Array.exists (fun package -> package.Name = "test")) "package index did not contain test script"
}
test "getScriptContent returns correct content" {
test "downloadPackageScript test_3_0_0" {
Expect.equal
(
AVPR.api.downloadPackageScript( "test", "3.0.0")
|> fun content -> content.ReplaceLineEndings()
|> fun content -> content.ReplaceLineEndings("\n")
)
ReferenceObjects.testScriptContentAVPR
ReferenceObjects.testScriptContentAVPR_test_3_0_0
"script content was not correct"
}
]
2 changes: 1 addition & 1 deletion tests/ARCValidationPackages.Tests/ConfigTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open TestUtils
[<Tests>]
let ``Config tests`` =
testSequenced (
testList "Config tests" [
testList "Domain Tests.Config tests" [

let testConfig =
Config.create(
Expand Down
2 changes: 1 addition & 1 deletion tests/ARCValidationPackages.Tests/DefaultsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ open TestUtils
[<Tests>]
let ``Defaults tests`` =
testSequenced (
testList "Defaults tests" [
testList "Domain Tests.Defaults tests" [
test "config folder path is correct" {
Expect.equal
(Defaults.CONFIG_FOLDER())
Expand Down
6 changes: 3 additions & 3 deletions tests/ARCValidationPackages.Tests/GitHubAPITests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let ``GitHubAPI tests`` =
response
|> fun json -> (json?content).GetString()
|> fun content -> Convert.FromBase64String(content)
|> fun bytes -> Encoding.UTF8.GetString(bytes).ReplaceLineEndings()
|> fun bytes -> Encoding.UTF8.GetString(bytes).ReplaceLineEndings("\n")
)
ReferenceObjects.testScriptContent
$"repository content was not correct{System.Environment.NewLine}{response}"
Expand All @@ -48,7 +48,7 @@ let ``GitHubAPI tests`` =
}
test "getPackageIndex contains test script" {
let indexedPackages = GitHubAPI.getPackageIndex(?Token = token)
Expect.isTrue (indexedPackages |> Array.exists (fun package -> package.RepoPath = "StagingArea/test/[email protected]")) "package index did not contain test script"
Expect.isTrue (indexedPackages |> Array.exists (fun package -> package.RepoPath = "./StagingArea/test/[email protected]")) "package index did not contain test script"
}
test "getScriptContent terminates" {
GitHubAPI.downloadPackageScript(
Expand All @@ -64,7 +64,7 @@ let ``GitHubAPI tests`` =
"StagingArea/test/[email protected]",
?Token = token
)
|> fun content -> content.ReplaceLineEndings()
|> fun content -> content.ReplaceLineEndings("\n")
)
ReferenceObjects.testScriptContent
"script content was not correct"
Expand Down
2 changes: 1 addition & 1 deletion tests/ARCValidationPackages.Tests/PackageCacheTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open System.Collections.Generic

[<Tests>]
let tests =
testSequenced (testList "PackageCache tests" [
testSequenced (testList "Domain Tests.PackageCache tests" [

test "createFromPackageList" {
Expect.packageCacheEqual
Expand Down
87 changes: 83 additions & 4 deletions tests/ARCValidationPackages.Tests/ReferenceObjects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ validationCases
|> Execute.ValidationPipeline(
basePath = System.Environment.CurrentDirectory,
packageName = "test"
)""" .ReplaceLineEndings()
)""" .ReplaceLineEndings("\n")

let testScriptContentAVPR = """(*
let testScriptContentAVPR_test_3_0_0 = """(*
---
Name: test
MajorVersion: 3
Expand Down Expand Up @@ -96,7 +96,53 @@ validationCases
|> Execute.ValidationPipeline(
basePath = System.Environment.CurrentDirectory,
packageName = "test"
)""" .ReplaceLineEndings()
)""" .ReplaceLineEndings("\n")

let testScriptContentAVPR_test_5_0_0 = "let [<Literal>]PACKAGE_METADATA = \"\"\"(*
---
Name: test
MajorVersion: 5
MinorVersion: 0
PatchVersion: 0
Publish: true
Summary: this package is here for testing purposes only.
Description: this package is here for testing purposes only.
Authors:
- FullName: John Doe
Email: [email protected]
Affiliation: University of Nowhere
AffiliationLink: https://nowhere.edu
- FullName: Jane Doe
Email: [email protected]
Affiliation: University of Somewhere
AffiliationLink: https://somewhere.edu
Tags:
- Name: validation
- Name: my-package
- Name: thing
ReleaseNotes: Use ARCExpect v3
CQCHookEndpoint: https://avpr.nfdi4plants.org
---
*)\"\"\"
printfn \"If you can read this in your console, you successfully executed test package v5.0.0!\"
#r \"nuget: ARCExpect, 3.0.0\"
open ARCExpect
open Expecto
let test_package =
Setup.ValidationPackage(
metadata = Setup.Metadata(PACKAGE_METADATA),
CriticalValidationCases = [
test \"yes\" {Expect.equal 1 1 \"yes\"}
]
)
test_package
|> Execute.ValidationPipeline(
basePath = System.Environment.CurrentDirectory
)" .ReplaceLineEndings("\n")

let testValidationPackage1 =
CachedValidationPackage.create(
Expand Down Expand Up @@ -157,4 +203,37 @@ let testScriptPath = "fixtures/testScript.fsx"
let testScriptArgsPath = "fixtures/testScriptArgs.fsx"

let testScriptPackage = CachedValidationPackage.create("testScript", testDate1, testScriptPath, ValidationPackageMetadata())
let testScriptArgsPackage = CachedValidationPackage.create("testScriptArgs", testDate1, testScriptArgsPath, ValidationPackageMetadata())
let testScriptArgsPackage = CachedValidationPackage.create("testScriptArgs", testDate1, testScriptArgsPath, ValidationPackageMetadata())

module AVPRClientDomain =
module ValidationPackage =
let testPackage_3_0_0 = AVPRClient.ValidationPackage(
Name = "test",
MajorVersion = 3,
MinorVersion = 0,
PatchVersion = 0,
Summary = "this package is here for testing purposes only.",
Description = "this package is here for testing purposes only.",
Authors = [|
AVPRClient.Author(
FullName = "John Doe",
Email = "[email protected]",
Affiliation = "University of Nowhere",
AffiliationLink = "https://nowhere.edu"
)
AVPRClient.Author(
FullName = "Jane Doe",
Email = "[email protected]",
Affiliation = "University of Somewhere",
AffiliationLink = "https://somewhere.edu"
)
|],
Tags = [|
AVPRClient.OntologyAnnotation(Name = "validation", TermAccessionNumber = "", TermSourceREF = "")
AVPRClient.OntologyAnnotation(Name = "my-package", TermAccessionNumber = "", TermSourceREF = "")
AVPRClient.OntologyAnnotation(Name = "thing", TermAccessionNumber = "", TermSourceREF = "")
|],
ReleaseNotes = "add authors and tags for further testing",
PackageContent = System.Text.Encoding.UTF8.GetBytes testScriptContentAVPR_test_3_0_0,
CQCHookEndpoint = ""
)
33 changes: 33 additions & 0 deletions tests/ARCValidationPackages.Tests/TestUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,39 @@ module Expect =
Expect.sequenceEqual expectedKeysSorted actualKeysSorted $"Keys were not equal."
Expect.sequenceEqual zippedValuesActual zippedValuesExpected "Values were not equal."

module AVPRClient =

let authorEqual (actual:AVPRClient.Author) (expected:AVPRClient.Author) =
Expect.equal actual.FullName expected.FullName "AVPRClient.Author Name not equal"
Expect.equal actual.Email expected.Email "AVPRClient.Author Email not equal"
Expect.equal actual.Affiliation expected.Affiliation "AVPRClient.Author Affiliation not equal"
Expect.equal actual.AffiliationLink expected.AffiliationLink "AVPRClient.Author AffiliationLink not equal"

let ontologyAnnotationTagEqual (actual:AVPRClient.OntologyAnnotation) (expected:AVPRClient.OntologyAnnotation) =
Expect.equal actual.Name expected.Name "AVPRClient.OntologyAnnotation Name not equal"
Expect.equal actual.TermAccessionNumber expected.TermAccessionNumber "AVPRClient.OntologyAnnotation TermAccessionNumber not equal"
Expect.equal actual.TermSourceREF expected.TermSourceREF "AVPRClient.OntologyAnnotation TermSourceREF not equal"

let validationPackageEqual (actual: AVPRClient.ValidationPackage) (expected:AVPRClient.ValidationPackage) =
Expect.equal actual.Name expected.Name "AVPRClient.ValidationPackage Name not equal"
Expect.equal actual.Summary expected.Summary "AVPRClient.ValidationPackage Summary not equal"
Expect.equal actual.MajorVersion expected.MajorVersion "AVPRClient.ValidationPackage MajorVersion not equal"
Expect.equal actual.MinorVersion expected.MinorVersion "AVPRClient.ValidationPackage MinorVersion not equal"
Expect.equal actual.PatchVersion expected.PatchVersion "AVPRClient.ValidationPackage PatchVersion not equal"
Expect.equal actual.ReleaseNotes expected.ReleaseNotes "AVPRClient.ValidationPackage ReleaseNotes not equal"
Expect.equal actual.CQCHookEndpoint expected.CQCHookEndpoint "AVPRClient.ValidationPackage CQCHookEndpoint not equal"

Seq.zip actual.Authors expected.Authors
|> Seq.iter (fun (actual, expected) -> authorEqual actual expected)

Seq.zip actual.Tags expected.Tags
|> Seq.iter (fun (actual, expected) -> ontologyAnnotationTagEqual actual expected)

Expect.sequenceEqual expected.Tags expected.Tags "AVPRClient.ValidationPackage Tags not equal"
Expect.sequenceEqual expected.PackageContent expected.PackageContent "AVPRClient.ValidationPackage PackageContent not equal"



module Result =

let okValue = function
Expand Down
6 changes: 3 additions & 3 deletions tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ let ``ValidateCommand CLI Tests`` =
(get_gh_api_token())
) [
"Package script exists in avpr cache after running package install test" ,
fun tool args proc -> Expect.isTrue (File.Exists(Path.Combine(expected_package_cache_folder_path_release, "test@3.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_release, "test@5.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args )
"Package script does not exist in preview cache after running package install test" ,
fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path_preview, "test@3.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args )
fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path_preview, "test@5.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args )

]
yield!
Expand All @@ -158,7 +158,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("If you can read this in your console, you successfully executed test package v3.0.0!")) (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 v5.0.0!")) (ErrorMessage.withProcessDiagnostics "incorrect console output" proc tool args )
]
])
])
Expand Down

0 comments on commit 9d19617

Please sign in to comment.