From a39258fd38046723792cb2529619baf723022f44 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 21 Jun 2024 14:25:37 +0200 Subject: [PATCH] Make staging area tests more robust, do not use binding frontmatter on first suffix test package --- StagingArea/test/test@5.0.0-use+suffixes.fsx | 29 ++++--------------- StagingAreaTests/FileContentTests.fs | 14 ++++++--- StagingAreaTests/PackageSanityChecks.fs | 7 +++-- StagingAreaTests/ReferenceObjects.fs | 16 +--------- StagingAreaTests/Utils.fs | 2 +- tests/ClientTests/ReferenceObjects.fs | 6 ++-- .../fixtures/allFields_semVerAddition.fsx | 4 +-- 7 files changed, 27 insertions(+), 51 deletions(-) diff --git a/StagingArea/test/test@5.0.0-use+suffixes.fsx b/StagingArea/test/test@5.0.0-use+suffixes.fsx index 5d4f8f0..3ee54e1 100644 --- a/StagingArea/test/test@5.0.0-use+suffixes.fsx +++ b/StagingArea/test/test@5.0.0-use+suffixes.fsx @@ -1,11 +1,11 @@ -let []PACKAGE_METADATA = """(* +(* --- Name: test MajorVersion: 5 MinorVersion: 0 PatchVersion: 0 -PreRelease: use -BuildMetadata: suffixes +PreReleaseVersionSuffix: use +BuildMetadataVersionSuffix: suffixes Publish: true Summary: this package is here for testing purposes only. Description: this package is here for testing purposes only. @@ -22,26 +22,9 @@ Tags: - Name: validation - Name: my-package - Name: thing -ReleaseNotes: Use ARCExpect v3 +ReleaseNotes: Use pre-release and build metadata version suffixes CQCHookEndpoint: https://avpr.nfdi4plants.org --- -*)""" +*) -printfn "If you can read this in your console, you successfully executed test package v5.0.0-use+suffixes!" - -#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 -) \ No newline at end of file +printfn "If you can read this in your console, you successfully executed test package v5.0.0-use+suffixes!" \ No newline at end of file diff --git a/StagingAreaTests/FileContentTests.fs b/StagingAreaTests/FileContentTests.fs index 8ac0570..07ea340 100644 --- a/StagingAreaTests/FileContentTests.fs +++ b/StagingAreaTests/FileContentTests.fs @@ -5,18 +5,24 @@ open System.IO open Xunit open Utils +open AVPRIndex + module FileContent = [] let ``All files have frontmatter`` () = Assert.All( - ReferenceObjects.all_staged_packages_contents, - snd >> Assert.ContainsFrontmatter + ReferenceObjects.all_staged_packages_paths, + File.ReadAllText >> (fun x -> x.ReplaceLineEndings("\n")) >> Assert.ContainsFrontmatter ) [] let ``All files have valid metadata`` () = Assert.All( - ReferenceObjects.all_staged_packages_metadata, - snd >> Assert.MetadataValid + ReferenceObjects.all_staged_packages_paths, + (fun p -> + p + |> ValidationPackageMetadata.extractFromScript + |> Assert.MetadataValid + ) ) \ No newline at end of file diff --git a/StagingAreaTests/PackageSanityChecks.fs b/StagingAreaTests/PackageSanityChecks.fs index 633cad3..2ec417b 100644 --- a/StagingAreaTests/PackageSanityChecks.fs +++ b/StagingAreaTests/PackageSanityChecks.fs @@ -5,16 +5,17 @@ open System.IO open Xunit open Utils +open AVPRIndex module Metadata = [] let ``Metadata versions match file names`` () = Assert.All( - ReferenceObjects.all_staged_packages_metadata, - (fun (path, metadata) -> + ReferenceObjects.all_staged_packages_paths, + (fun path -> let file_name_version = (Path.GetFileNameWithoutExtension path).Split('@')[1] - let metadata_version = sprintf "%i.%i.%i" metadata.MajorVersion metadata.MinorVersion metadata.PatchVersion + let metadata_version = path |> ValidationPackageMetadata.extractFromScript |> ValidationPackageMetadata.getSemanticVersionString Assert.Equal(file_name_version, metadata_version) ) ) diff --git a/StagingAreaTests/ReferenceObjects.fs b/StagingAreaTests/ReferenceObjects.fs index 9844e5e..8bc4eaf 100644 --- a/StagingAreaTests/ReferenceObjects.fs +++ b/StagingAreaTests/ReferenceObjects.fs @@ -15,18 +15,4 @@ let all_files_in_staging_area = let all_staged_packages_paths = Directory.GetFiles(staging_area_root, "*.fsx", SearchOption.AllDirectories) - |> Array.map (fun x -> x.Replace('\\',Path.DirectorySeparatorChar).Replace('/',Path.DirectorySeparatorChar)) - -let all_staged_packages_contents = - all_staged_packages_paths - |> Array.map (fun p -> - p, - p |> (File.ReadAllText >> fun x -> x.ReplaceLineEndings("\n")) - ) - -let all_staged_packages_metadata = - all_staged_packages_paths - |> Array.map (fun p -> - p, - ValidationPackageMetadata.extractFromScript p - ) \ No newline at end of file + |> Array.map (fun x -> x.Replace('\\',Path.DirectorySeparatorChar).Replace('/',Path.DirectorySeparatorChar)) \ No newline at end of file diff --git a/StagingAreaTests/Utils.fs b/StagingAreaTests/Utils.fs index eda7511..1ac3d29 100644 --- a/StagingAreaTests/Utils.fs +++ b/StagingAreaTests/Utils.fs @@ -41,5 +41,5 @@ type Assert with static member FileNameValid(path:string) = let fileName = Path.GetFileName(path) let folderName = Path.GetDirectoryName(path) |> Path.GetFileName - let pattern = sprintf @"^%s@\d+\.\d+\.\d+\.fsx$" folderName + let pattern = sprintf @"^%s@%s.fsx$" folderName AVPRIndex.Globals.SEMVER_REGEX_PATTERN[1.. (AVPRIndex.Globals.SEMVER_REGEX_PATTERN.Length - 2)] // first and last characters of that regex are start/end signifiers Assert.Matches(pattern, fileName) \ No newline at end of file diff --git a/tests/ClientTests/ReferenceObjects.fs b/tests/ClientTests/ReferenceObjects.fs index 9c2ea2e..3b2598a 100644 --- a/tests/ClientTests/ReferenceObjects.fs +++ b/tests/ClientTests/ReferenceObjects.fs @@ -103,7 +103,7 @@ module Hash = Hash = expected_hash_cqcHookAddition ) - let expected_hash_semVerAddition = "2A546201341641AAB21FB49DADD06676" + let expected_hash_semVerAddition = "E3D3C259C4B3F54783283735B20F8C23" let allFields_semVerAddition = AVPRClient.PackageContentHash( PackageName = "name", @@ -154,8 +154,8 @@ Description = description MajorVersion: 1 MinorVersion: 0 PatchVersion: 0 -PreRelease: use -BuildMetadata: suffixes +PreReleaseVersionSuffix: use +BuildMetadataVersionSuffix: suffixes Publish: true Authors: - FullName: test diff --git a/tests/ClientTests/fixtures/allFields_semVerAddition.fsx b/tests/ClientTests/fixtures/allFields_semVerAddition.fsx index f2c73ca..29a0fe8 100644 --- a/tests/ClientTests/fixtures/allFields_semVerAddition.fsx +++ b/tests/ClientTests/fixtures/allFields_semVerAddition.fsx @@ -6,8 +6,8 @@ Description = description MajorVersion: 1 MinorVersion: 0 PatchVersion: 0 -PreRelease: use -BuildMetadata: suffixes +PreReleaseVersionSuffix: use +BuildMetadataVersionSuffix: suffixes Publish: true Authors: - FullName: test