From 2e0560072d3ff4be6a32def689ca90106273c760 Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Fri, 1 Mar 2024 13:59:30 +0100 Subject: [PATCH 1/6] add avpr client and index --- src/ARCValidationPackages/ARCValidationPackages.fsproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ARCValidationPackages/ARCValidationPackages.fsproj b/src/ARCValidationPackages/ARCValidationPackages.fsproj index db0bc2a..6fe5d26 100644 --- a/src/ARCValidationPackages/ARCValidationPackages.fsproj +++ b/src/ARCValidationPackages/ARCValidationPackages.fsproj @@ -22,6 +22,8 @@ + + From 3bffce0ad02ea9706e89fb200bb00381ca41fd3e Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Fri, 1 Mar 2024 14:51:55 +0100 Subject: [PATCH 2/6] switch to AVPRIndex domain, rename ARC- to CachedValidationPackage --- .../ARCValidationPackages.fsproj | 1 + src/ARCValidationPackages/AVPRAPI.fs | 34 +++++++ src/ARCValidationPackages/Config.fs | 1 + src/ARCValidationPackages/Domain.fs | 91 +++---------------- src/ARCValidationPackages/GitHubAPI.fs | 1 + src/ARCValidationPackages/PackageCache.fs | 25 ++--- src/ARCValidationPackages/ScriptExecution.fs | 4 +- src/ARCValidationPackages/TopLevelAPI.fs | 3 +- 8 files changed, 65 insertions(+), 95 deletions(-) create mode 100644 src/ARCValidationPackages/AVPRAPI.fs diff --git a/src/ARCValidationPackages/ARCValidationPackages.fsproj b/src/ARCValidationPackages/ARCValidationPackages.fsproj index 6fe5d26..a177b41 100644 --- a/src/ARCValidationPackages/ARCValidationPackages.fsproj +++ b/src/ARCValidationPackages/ARCValidationPackages.fsproj @@ -12,6 +12,7 @@ + diff --git a/src/ARCValidationPackages/AVPRAPI.fs b/src/ARCValidationPackages/AVPRAPI.fs new file mode 100644 index 0000000..4409988 --- /dev/null +++ b/src/ARCValidationPackages/AVPRAPI.fs @@ -0,0 +1,34 @@ +namespace ARCValidationPackages + +open AVPRClient +open ARCValidationPackages +open AVPRIndex +open System +open System.Net.Http + +type AVPRAPI () = + member private this.BaseUri = Uri("https://avpr.nfdi4plants.org") + member private this.HttpClienHandler = new HttpClientHandler (UseCookies = false) + member private this.HttpClient = new HttpClient(this.HttpClienHandler, true, BaseAddress=this.BaseUri) + member this.Client = AVPRClient.Client(this.HttpClient) + member this.GetAllPackages (): ValidationPackage [] = + this.Client.GetAllPackagesAsync(System.Threading.CancellationToken.None) + |> Async.AwaitTask + |> Async.RunSynchronously + |> Seq.toArray + member this.GetPackageByName (packageName: string): ValidationPackage = + this.Client.GetLatestPackageByNameAsync(packageName) + |> Async.AwaitTask + |> Async.RunSynchronously + member this.GetPackageByNameAndVersion (packageName: string) (version: string): ValidationPackage = + this.Client.GetPackageByNameAndVersionAsync(packageName, version) + |> Async.AwaitTask + |> Async.RunSynchronously + + //member this.downloadPackageScript (packageIndex: ValidationPackageIndex) = + + // let validationPackage = + // this.GetPackageByNameAndVersion + // packageIndex.Metadata.Name + // (ValidationPackageMetadata.getSemanticVersionString packageIndex.Metadata) + // Text.Encoding.UTF8.GetString validationPackage.PackageContent \ No newline at end of file diff --git a/src/ARCValidationPackages/Config.fs b/src/ARCValidationPackages/Config.fs index 4bed9f6..d7a2a3e 100644 --- a/src/ARCValidationPackages/Config.fs +++ b/src/ARCValidationPackages/Config.fs @@ -1,6 +1,7 @@ namespace ARCValidationPackages open System.IO open System.Text.Json +open AVPRIndex.Domain type Config = { PackageIndex: ValidationPackageIndex [] diff --git a/src/ARCValidationPackages/Domain.fs b/src/ARCValidationPackages/Domain.fs index 12b1273..74a5b64 100644 --- a/src/ARCValidationPackages/Domain.fs +++ b/src/ARCValidationPackages/Domain.fs @@ -3,88 +3,19 @@ open System.IO open System.Text.Json open System.Text.Json.Serialization +open AVPRIndex.Domain +open System.Runtime.CompilerServices -// must be a class to be deserializable with YamlDotNet -/// -/// Represents the metadata of a validation package, e.g. version, name and description. -/// -type ValidationPackageMetadata() = - 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 - - override this.GetHashCode() = - hash (this.Name, this.Description, this.MajorVersion, this.MinorVersion, this.PatchVersion) - - 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) - | _ -> false - static member create ( - name: string, - description: string, - majorVersion: int, - minorVersion: int, - patchVersion: int - ) = - let tmp = ValidationPackageMetadata() - tmp.Name <- name - tmp.Description <- description - tmp.MajorVersion <- majorVersion - tmp.MinorVersion <- minorVersion - tmp.PatchVersion <- patchVersion - tmp - - static member getSemanticVersionString(m: ValidationPackageMetadata) = $"{m.MajorVersion}.{m.MinorVersion}.{m.PatchVersion}"; - -/// -/// represents a remotely available version of a validation package, e.g. the path to the file on GitHub and the date it was last updated. -/// -type ValidationPackageIndex = - { - RepoPath: string - FileName:string - LastUpdated: System.DateTimeOffset - Metadata: ValidationPackageMetadata - } with - static member create ( - repoPath: string, - fileName: string, - lastUpdated: System.DateTimeOffset, - metadata: ValidationPackageMetadata - - ) = - { - RepoPath = repoPath - FileName = fileName - LastUpdated = lastUpdated - Metadata = metadata - } - static member create ( - repoPath: string, - lastUpdated: System.DateTimeOffset, - metadata: ValidationPackageMetadata - ) = - ValidationPackageIndex.create( - repoPath = repoPath, - fileName = Path.GetFileNameWithoutExtension(repoPath), - lastUpdated = lastUpdated, - metadata = metadata - ) - - static member getSemanticVersionString(i: ValidationPackageIndex) = $"{i.Metadata.MajorVersion}.{i.Metadata.MinorVersion}.{i.Metadata.PatchVersion}"; - - member this.PrettyPrint() = - $" {this.Metadata.Name} @ version {this.Metadata.MajorVersion}.{this.Metadata.MinorVersion}.{this.Metadata.PatchVersion}{System.Environment.NewLine}{_.Metadata.Description}{System.Environment.NewLine}Last Updated: {this.LastUpdated}{System.Environment.NewLine}" +module ValidationPackageMetadata = + let getSemanticVersionString(m: ValidationPackageMetadata) = $"{m.MajorVersion}.{m.MinorVersion}.{m.PatchVersion}" +module ValidationPackageIndex = + let getSemanticVersionString(i: ValidationPackageIndex) = $"{i.Metadata.MajorVersion}.{i.Metadata.MinorVersion}.{i.Metadata.PatchVersion}" /// /// represents the locally installed version of a validation package, e.g. the path to the local file and the date it was cached. /// -type ARCValidationPackage = +type CachedValidationPackage = { FileName: string CacheDate: System.DateTimeOffset @@ -111,7 +42,7 @@ type ARCValidationPackage = /// Optional. The date to set the CacheDate to. Defaults to the current date. static member ofPackageIndex (packageIndex: ValidationPackageIndex, ?Date: System.DateTimeOffset, ?CacheFolder: string) = let path = defaultArg CacheFolder (Defaults.PACKAGE_CACHE_FOLDER()) - ARCValidationPackage.create( + CachedValidationPackage.create( fileName = packageIndex.FileName, cacheDate = (defaultArg Date System.DateTimeOffset.Now), localPath = (System.IO.Path.Combine(path, packageIndex.FileName).Replace("\\","/")), @@ -126,7 +57,7 @@ type ARCValidationPackage = /// static member ofPackageName (packageName: string, ?Date: System.DateTimeOffset, ?Path: string) = let path = defaultArg Path (Defaults.PACKAGE_CACHE_FOLDER()) - ARCValidationPackage.create( + CachedValidationPackage.create( fileName = packageName, cacheDate = (defaultArg Date System.DateTimeOffset.Now), localPath = (System.IO.Path.Combine(path, $"{packageName}.fsx").Replace("\\","/")), @@ -138,10 +69,10 @@ type ARCValidationPackage = /// /// The date to set the CacheDate to /// The input package - static member updateCacheDate (date: System.DateTimeOffset) (package: ARCValidationPackage) = + static member updateCacheDate (date: System.DateTimeOffset) (package: CachedValidationPackage) = {package with CacheDate = date} - static member getSemanticVersionString(vp: ARCValidationPackage) = $"{vp.Metadata.MajorVersion}.{vp.Metadata.MinorVersion}.{vp.Metadata.PatchVersion}"; + static member getSemanticVersionString(vp: CachedValidationPackage) = $"{vp.Metadata.MajorVersion}.{vp.Metadata.MinorVersion}.{vp.Metadata.PatchVersion}"; member this.PrettyPrint() = $" {this.Metadata.Name} @ version {this.Metadata.MajorVersion}.{this.Metadata.MinorVersion}.{this.Metadata.PatchVersion}{System.Environment.NewLine}{this.Metadata.Description}{System.Environment.NewLine}CacheDate: {this.CacheDate}{System.Environment.NewLine}Installed at: {this.LocalPath}{System.Environment.NewLine}" \ No newline at end of file diff --git a/src/ARCValidationPackages/GitHubAPI.fs b/src/ARCValidationPackages/GitHubAPI.fs index 8b60e69..f0c67de 100644 --- a/src/ARCValidationPackages/GitHubAPI.fs +++ b/src/ARCValidationPackages/GitHubAPI.fs @@ -5,6 +5,7 @@ open System open System.IO open System.Text open System.Text.Json +open AVPRIndex.Domain module GitHubAPI = diff --git a/src/ARCValidationPackages/PackageCache.fs b/src/ARCValidationPackages/PackageCache.fs index 304aaed..e7520bd 100644 --- a/src/ARCValidationPackages/PackageCache.fs +++ b/src/ARCValidationPackages/PackageCache.fs @@ -3,13 +3,14 @@ open System.Collections.Generic open System.IO open System.Text.Json +open AVPRIndex.Domain type PackageCache = - inherit Dictionary> + inherit Dictionary> - new () = { inherit Dictionary>() } + new () = { inherit Dictionary>() } - new (packages: IEnumerable>>) = { inherit Dictionary>(packages) } + new (packages: IEnumerable>>) = { inherit Dictionary>(packages) } new (cache: PackageCache) = let kv = @@ -21,14 +22,14 @@ type PackageCache = PackageCache(kv) - new(packages: seq) = + new(packages: seq) = let kv = packages |> Seq.groupBy (fun p -> p.Metadata.Name) |> Seq.map (fun (name,packages) -> name, packages - |> Seq.map (fun p -> KeyValuePair.Create(ARCValidationPackage.getSemanticVersionString p, p) ) + |> Seq.map (fun p -> KeyValuePair.Create(CachedValidationPackage.getSemanticVersionString p, p) ) |> Dictionary ) |> Seq.map (fun (name,versions) -> KeyValuePair.Create(name,versions)) @@ -57,7 +58,7 @@ type PackageCache = // false // | _ -> false - static member create (packages: seq) = + static member create (packages: seq) = new PackageCache(packages) static member getPackage (name: string) (semVerString: string) (cache: PackageCache) = @@ -65,7 +66,7 @@ type PackageCache = static member getLatestPackage (name: string) (cache: PackageCache) = cache[name] - |> Seq.maxBy (fun (kv:KeyValuePair) -> kv.Key) + |> Seq.maxBy (fun (kv:KeyValuePair) -> kv.Key) |> fun x -> x.Value static member getPackages (name: string) (cache: PackageCache) = @@ -104,16 +105,16 @@ type PackageCache = else None - static member addPackage (package: ARCValidationPackage) (cache: PackageCache) = + static member addPackage (package: CachedValidationPackage) (cache: PackageCache) = - let semver = ARCValidationPackage.getSemanticVersionString package + let semver = CachedValidationPackage.getSemanticVersionString package if cache.ContainsKey(package.Metadata.Name) then cache[package.Metadata.Name].Add(semver, package) else cache.Add( package.Metadata.Name, - new Dictionary([KeyValuePair.Create(semver, package)]) + new Dictionary([KeyValuePair.Create(semver, package)]) ) cache @@ -121,11 +122,11 @@ type PackageCache = static member cachePackageOfIndex (packageIndex: ValidationPackageIndex, ?Date: System.DateTimeOffset) = fun (cache: PackageCache) -> cache - |> PackageCache.addPackage (ARCValidationPackage.ofPackageIndex(packageIndex, ?Date = Date)) + |> PackageCache.addPackage (CachedValidationPackage.ofPackageIndex(packageIndex, ?Date = Date)) static member updateCacheDate (name: string) (semVerString: string) (date: System.DateTimeOffset) (cache: PackageCache) = let package = cache.[name][semVerString] - cache.[name][semVerString] <- package |> ARCValidationPackage.updateCacheDate date + cache.[name][semVerString] <- package |> CachedValidationPackage.updateCacheDate date cache static member tryUpdateCacheDate (name: string) (semVerString: string) (date: System.DateTimeOffset) (cache: PackageCache) = diff --git a/src/ARCValidationPackages/ScriptExecution.fs b/src/ARCValidationPackages/ScriptExecution.fs index 1470964..ae7e225 100644 --- a/src/ARCValidationPackages/ScriptExecution.fs +++ b/src/ARCValidationPackages/ScriptExecution.fs @@ -21,8 +21,8 @@ type ScriptExecution = static member runScript (scriptPath: string) = ScriptExecution.runScriptWithArgs scriptPath [||] - static member runPackageScriptWithArgs (package: ARCValidationPackage) (args: string []) = + static member runPackageScriptWithArgs (package: CachedValidationPackage) (args: string []) = ScriptExecution.runScriptWithArgs package.LocalPath args - static member runPackageScript (package: ARCValidationPackage) = + static member runPackageScript (package: CachedValidationPackage) = ScriptExecution.runPackageScriptWithArgs package [||] diff --git a/src/ARCValidationPackages/TopLevelAPI.fs b/src/ARCValidationPackages/TopLevelAPI.fs index 14a5360..c89180b 100644 --- a/src/ARCValidationPackages/TopLevelAPI.fs +++ b/src/ARCValidationPackages/TopLevelAPI.fs @@ -1,5 +1,6 @@ namespace ARCValidationPackages open System.IO +open AVPRIndex.Domain type APIError = | RateLimitExceeded of msg: string @@ -151,7 +152,7 @@ type API = match API.UpdateIndex(config, ?Token = Token) with | Ok updatedConfig -> - let updatedIndexPackage = Config.getIndexedPackageByNameAndVersion packageName (ARCValidationPackage.getSemanticVersionString cachedPackage) updatedConfig + let updatedIndexPackage = Config.getIndexedPackageByNameAndVersion packageName (CachedValidationPackage.getSemanticVersionString cachedPackage) updatedConfig if updatedIndexPackage.LastUpdated > indexedPackage.LastUpdated then // package on remote index is newer, download package and cache. if verbose then printfn $"package {packageName} is available in a newer version({updatedIndexPackage.LastUpdated} vs {indexedPackage.LastUpdated}). downloading..." From eabf276366d049f800f1e479175878d8d965095c Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Mon, 4 Mar 2024 11:01:59 +0100 Subject: [PATCH 3/6] adapt test for new AVPRIndex package --- .../ARCValidationPackages.fsproj | 2 +- .../ARCValidationPackageTests.fs | 4 +- .../ARCValidationPackages.Tests.fsproj | 1 + .../PackageCacheTests.fs | 4 +- .../ReferenceObjects.fs | 66 +++++++++++++------ .../ARCValidationPackages.Tests/TestUtils.fs | 4 +- .../TopLevelAPITests.fs | 1 + 7 files changed, 54 insertions(+), 28 deletions(-) diff --git a/src/ARCValidationPackages/ARCValidationPackages.fsproj b/src/ARCValidationPackages/ARCValidationPackages.fsproj index a177b41..0f46b32 100644 --- a/src/ARCValidationPackages/ARCValidationPackages.fsproj +++ b/src/ARCValidationPackages/ARCValidationPackages.fsproj @@ -24,7 +24,7 @@ - + diff --git a/tests/ARCValidationPackages.Tests/ARCValidationPackageTests.fs b/tests/ARCValidationPackages.Tests/ARCValidationPackageTests.fs index f926852..7f780f9 100644 --- a/tests/ARCValidationPackages.Tests/ARCValidationPackageTests.fs +++ b/tests/ARCValidationPackages.Tests/ARCValidationPackageTests.fs @@ -13,7 +13,7 @@ let tests = Expect.equal ( testValidationPackage1 - |> ARCValidationPackage.updateCacheDate testDate2 + |> CachedValidationPackage.updateCacheDate testDate2 ) testValidationPackage2 "ARCValidationPackage cache date was not updated correctly." @@ -21,7 +21,7 @@ let tests = test "ofPackageIndex" { Expect.equal ( - ARCValidationPackage.ofPackageIndex( + CachedValidationPackage.ofPackageIndex( packageIndex = testPackageIndex[0], Date = testDate2 ) diff --git a/tests/ARCValidationPackages.Tests/ARCValidationPackages.Tests.fsproj b/tests/ARCValidationPackages.Tests/ARCValidationPackages.Tests.fsproj index a8ca740..edfd1c9 100644 --- a/tests/ARCValidationPackages.Tests/ARCValidationPackages.Tests.fsproj +++ b/tests/ARCValidationPackages.Tests/ARCValidationPackages.Tests.fsproj @@ -25,6 +25,7 @@ + diff --git a/tests/ARCValidationPackages.Tests/PackageCacheTests.fs b/tests/ARCValidationPackages.Tests/PackageCacheTests.fs index e593a82..7bba3ed 100644 --- a/tests/ARCValidationPackages.Tests/PackageCacheTests.fs +++ b/tests/ARCValidationPackages.Tests/PackageCacheTests.fs @@ -17,7 +17,7 @@ let tests = (PackageCache([testValidationPackage1])) ( let tmp = PackageCache() - let inner = new Dictionary() + let inner = new Dictionary() inner["1.0.0"] <- testValidationPackage1 tmp["test"] <- inner tmp @@ -56,7 +56,7 @@ let tests = Expect.packageCacheEqual ( PackageCache(testPackageCache1) - |> PackageCache.updateCacheDate testValidationPackage1.Metadata.Name (ARCValidationPackage.getSemanticVersionString testValidationPackage1) testDate2 + |> PackageCache.updateCacheDate testValidationPackage1.Metadata.Name (CachedValidationPackage.getSemanticVersionString testValidationPackage1) testDate2 ) testPackageCache2 } |> testSequenced diff --git a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs index 277f7cf..4f222d9 100644 --- a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs +++ b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs @@ -6,6 +6,7 @@ open type System.Environment open ARCValidationPackages open Common.TestUtils open TestUtils +open AVPRIndex.Domain let testDate1 = System.DateTimeOffset.ParseExact("2023-08-15 10:00:00 +02:00", "yyyy-MM-dd HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture) @@ -18,6 +19,7 @@ let testPackageIndex = repoPath = "arc-validate-packages/test.fsx", fileName = "test@1.0.0.fsx", lastUpdated = testDate1, + contentHash = "", metadata = ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", 1, 0, 0) ) |] @@ -52,51 +54,73 @@ validationCases )""" .ReplaceLineEndings() let testValidationPackage1 = - ARCValidationPackage.create( + CachedValidationPackage.create( "test@1.0.0.fsx", testDate1, (Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx").Replace("\\","/")), - ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", 1, 0, 0) + ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", "this package is here for testing purposes only.", 1, 0, 0) ) let testValidationPackage2 = - ARCValidationPackage.create( + CachedValidationPackage.create( "test@1.0.0.fsx", testDate2, (Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx").Replace("\\","/")), - ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", 1, 0, 0) + ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", "this package is here for testing purposes only.", 1, 0, 0) ) let testValidationPackage3FullMetadata = - ARCValidationPackage.create( + CachedValidationPackage.create( "test@3.0.0.fsx", testDate3, (Path.Combine(expected_package_cache_folder_path, "test@3.0.0.fsx").Replace("\\","/")), ValidationPackageMetadata.create( - "test", + "test", + "this package is here for testing purposes only.", "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" + let author1 = new Author() + let author2 = new Author() + ( + author1.FullName <- "John Doe" + author1.Email <- "j@d.com" + author1.Affiliation <- "University of Nowhere" + author1.AffiliationLink <- "https://nowhere.edu" ) - Author.create( - fullName = "Jane Doe", - email = "jj@d.com", - Affiliation = "University of Somewhere", - AffiliationLink = "https://somewhere.edu" + ( + author2.FullName <- "Jane Doe" + author2.Email <- "jj@d.com" + author2.Affiliation <- "University of Somewhere" + author2.AffiliationLink <- "https://somewhere.edu" ) + author1; author2 + //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" + let annotation1 = new OntologyAnnotation () + let annotation2 = new OntologyAnnotation () + let annotation3 = new OntologyAnnotation () + annotation1.Name <- "validation" + annotation2.Name <- "my-package" + annotation3.Name <- "thing" + annotation1 + annotation2 + annotation3 |], ReleaseNotes = "add authors and tags for further testing" ) @@ -108,5 +132,5 @@ let testPackageCache2 = PackageCache([testValidationPackage2]) let testScriptPath = "fixtures/testScript.fsx" let testScriptArgsPath = "fixtures/testScriptArgs.fsx" -let testScriptPackage = ARCValidationPackage.create("testScript", testDate1, testScriptPath, ValidationPackageMetadata()) -let testScriptArgsPackage = ARCValidationPackage.create("testScriptArgs", testDate1, testScriptArgsPath, ValidationPackageMetadata()) \ No newline at end of file +let testScriptPackage = CachedValidationPackage.create("testScript", testDate1, testScriptPath, ValidationPackageMetadata()) +let testScriptArgsPackage = CachedValidationPackage.create("testScriptArgs", testDate1, testScriptArgsPath, ValidationPackageMetadata()) \ No newline at end of file diff --git a/tests/ARCValidationPackages.Tests/TestUtils.fs b/tests/ARCValidationPackages.Tests/TestUtils.fs index 2fd8898..e51ee64 100644 --- a/tests/ARCValidationPackages.Tests/TestUtils.fs +++ b/tests/ARCValidationPackages.Tests/TestUtils.fs @@ -32,8 +32,8 @@ module Expect = with _ -> false ) - let mutable zippedValuesActual: seq<(string*string*ARCValidationPackage)> = Seq.empty - let mutable zippedValuesExpected: seq<(string*string*ARCValidationPackage)> = Seq.empty + let mutable zippedValuesActual: seq<(string*string*CachedValidationPackage)> = Seq.empty + let mutable zippedValuesExpected: seq<(string*string*CachedValidationPackage)> = Seq.empty if innerKeysAreEqual && KeysAreEqual then zippedValuesActual <- diff --git a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs index e395685..c56eea7 100644 --- a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs +++ b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs @@ -7,6 +7,7 @@ open System.IO open Common.TestUtils open TestUtils open ReferenceObjects +open AVPRIndex.Domain [] let ``Toplevel API tests`` = From 22a52e88a27dc66eff29674302ffd9318afabfa4 Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Mon, 4 Mar 2024 11:06:14 +0100 Subject: [PATCH 4/6] correct type --- src/ARCValidationPackages/PackageCache.fs | 2 +- src/ARCValidationPackages/TopLevelAPI.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ARCValidationPackages/PackageCache.fs b/src/ARCValidationPackages/PackageCache.fs index e7520bd..08625d9 100644 --- a/src/ARCValidationPackages/PackageCache.fs +++ b/src/ARCValidationPackages/PackageCache.fs @@ -10,7 +10,7 @@ type PackageCache = new () = { inherit Dictionary>() } - new (packages: IEnumerable>>) = { inherit Dictionary>(packages) } + new (packages: IEnumerable>>) = { inherit Dictionary>(packages) } new (cache: PackageCache) = let kv = diff --git a/src/ARCValidationPackages/TopLevelAPI.fs b/src/ARCValidationPackages/TopLevelAPI.fs index c89180b..c0e16d9 100644 --- a/src/ARCValidationPackages/TopLevelAPI.fs +++ b/src/ARCValidationPackages/TopLevelAPI.fs @@ -51,7 +51,7 @@ type API = ?Token: string ) = - let package = ARCValidationPackage.ofPackageIndex(indexedPackage, ?CacheFolder = CacheFolder) + let package = CachedValidationPackage.ofPackageIndex(indexedPackage, ?CacheFolder = CacheFolder) try GitHubAPI.downloadPackageScript(indexedPackage, ?Token = Token) |> fun script -> From fa8a94992859a41d8333515a93d2844d92c4fb98 Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Mon, 4 Mar 2024 11:37:44 +0100 Subject: [PATCH 5/6] fix lineendings and type reference --- src/arc-validate/APIs/PackageAPI.fs | 3 ++- src/arc-validate/arc-validate.fsproj | 1 + .../ARCValidationPackages.Tests/ReferenceObjects.fs | 5 +++-- tests/arc-validate.Tests/ReferenceObjects.fs | 12 +++++++----- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/arc-validate/APIs/PackageAPI.fs b/src/arc-validate/APIs/PackageAPI.fs index 6a408dc..14cecb3 100644 --- a/src/arc-validate/APIs/PackageAPI.fs +++ b/src/arc-validate/APIs/PackageAPI.fs @@ -5,6 +5,7 @@ open ARCValidate.CLIArguments open ARCValidate.CLICommands open ARCExpect open ARCValidationPackages +open AVPRIndex.Domain open Argu @@ -98,7 +99,7 @@ type PackageAPI = | Ok (config, cache) -> let verbose = defaultArg Verbose false - let printCachedPackageList (packages: seq) = + let printCachedPackageList (packages: seq) = packages |> fun p -> if Seq.length p = 0 then diff --git a/src/arc-validate/arc-validate.fsproj b/src/arc-validate/arc-validate.fsproj index 285b3dd..a3ff0bb 100644 --- a/src/arc-validate/arc-validate.fsproj +++ b/src/arc-validate/arc-validate.fsproj @@ -28,6 +28,7 @@ + diff --git a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs index 4f222d9..4b9dcf3 100644 --- a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs +++ b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs @@ -20,13 +20,14 @@ let testPackageIndex = fileName = "test@1.0.0.fsx", lastUpdated = testDate1, contentHash = "", - metadata = ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", 1, 0, 0) + metadata = ValidationPackageMetadata.create("test","this package is here for testing purposes only.", "this package is here for testing purposes only.", 1, 0, 0) ) |] let testScriptContent = """(* --- Name: test +Summary: this package is here for testing purposes only. Description: this package is here for testing purposes only. MajorVersion: 1 MinorVersion: 0 @@ -34,7 +35,7 @@ PatchVersion: 0 Publish: true --- *) - + // this file is intended for testing purposes only. printfn "If you can read this in your console, you successfully executed test package v1.0.0!" diff --git a/tests/arc-validate.Tests/ReferenceObjects.fs b/tests/arc-validate.Tests/ReferenceObjects.fs index 85276b6..436cc2e 100644 --- a/tests/arc-validate.Tests/ReferenceObjects.fs +++ b/tests/arc-validate.Tests/ReferenceObjects.fs @@ -10,6 +10,7 @@ let ``invenio test arc validation results`` = ValidationResults.fromJUnitFile "f let test_package_script_content_v1 = """(* --- Name: test +Summary: this package is here for testing purposes only. Description: this package is here for testing purposes only. MajorVersion: 1 MinorVersion: 0 @@ -17,7 +18,7 @@ PatchVersion: 0 Publish: true --- *) - + // this file is intended for testing purposes only. printfn "If you can read this in your console, you successfully executed test package v1.0.0!" @@ -43,6 +44,7 @@ MajorVersion: 2 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 @@ -54,13 +56,13 @@ Authors: Affiliation: University of Somewhere AffiliationLink: https://somewhere.edu Tags: - - validation - - my-package - - thing + - Name: validation + - Name: my-package + - Name: thing ReleaseNotes: "add authors and tags for further testing" --- *) - + // this file is intended for testing purposes only. printfn "If you can read this in your console, you successfully executed test package v2.0.0!" From 2ff0ed649551582653719073f1e043fb1b62d677 Mon Sep 17 00:00:00 2001 From: Caroline Ott Date: Mon, 4 Mar 2024 15:32:04 +0100 Subject: [PATCH 6/6] separate package cache in preview and release --- src/ARCValidationPackages/Config.fs | 2 +- src/ARCValidationPackages/Defaults.fs | 23 +++++++++++---- src/ARCValidationPackages/Domain.fs | 4 +-- src/ARCValidationPackages/PackageCache.fs | 8 +++--- src/ARCValidationPackages/TopLevelAPI.fs | 1 + .../ConfigTests.fs | 4 +-- .../DefaultsTests.fs | 10 +++---- .../PackageCacheTests.fs | 2 +- .../ReferenceObjects.fs | 6 ++-- .../TopLevelAPITests.fs | 2 +- tests/Common/TestUtils.fs | 14 ++++++---- .../CLITests/PackageCommandTests.fs | 28 +++++++++---------- .../CLITests/ValidateCommandTests.fs | 4 +-- 13 files changed, 63 insertions(+), 45 deletions(-) diff --git a/src/ARCValidationPackages/Config.fs b/src/ARCValidationPackages/Config.fs index d7a2a3e..abe607a 100644 --- a/src/ARCValidationPackages/Config.fs +++ b/src/ARCValidationPackages/Config.fs @@ -26,7 +26,7 @@ type Config = { Config.create( packageIndex = GitHubAPI.getPackageIndex(?Token = Token), indexLastUpdated = System.DateTimeOffset.Now, - packageCacheFolder = defaultArg CacheFolder (Defaults.PACKAGE_CACHE_FOLDER()), + packageCacheFolder = defaultArg CacheFolder (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()), configFilePath = defaultArg ConfigPath (Defaults.CONFIG_FILE_PATH()) ) static member indexContainsPackages (packageName: string) (config: Config) = diff --git a/src/ARCValidationPackages/Defaults.fs b/src/ARCValidationPackages/Defaults.fs index 4c1022e..57ce0de 100644 --- a/src/ARCValidationPackages/Defaults.fs +++ b/src/ARCValidationPackages/Defaults.fs @@ -24,7 +24,9 @@ module Defaults = let [] CONFIG_FILE_NAME = "validation-packages-config.json" - let [] PACKAGE_CACHE_FOLDER_NAME = "package-cache" + let [] PACKAGE_CACHE_FOLDER_NAME_PREVIEW = "package-cache-preview" + + let [] PACKAGE_CACHE_FOLDER_NAME_RELEASE = "package-cache-release" let [] PACKAGE_CACHE_FILE_NAME = "validation-packages-cache.json" @@ -44,15 +46,26 @@ module Defaults = Path.Combine(CONFIG_FOLDER(), CONFIG_FILE_NAME) .Replace("\\", "/") - let PACKAGE_CACHE_FOLDER () = + let PACKAGE_CACHE_FOLDER_PREVIEW () = + let path = + Path.Combine(CONFIG_FOLDER(), PACKAGE_CACHE_FOLDER_NAME_PREVIEW) + .Replace("\\", "/") + Directory.CreateDirectory(path) |> ignore + path + + let PACKAGE_CACHE_FOLDER_RELEASE () = let path = - Path.Combine(CONFIG_FOLDER(), PACKAGE_CACHE_FOLDER_NAME) + Path.Combine(CONFIG_FOLDER(), PACKAGE_CACHE_FOLDER_NAME_RELEASE) .Replace("\\", "/") Directory.CreateDirectory(path) |> ignore path - let PACKAGE_CACHE_FILE_PATH () = - Path.Combine(PACKAGE_CACHE_FOLDER(), PACKAGE_CACHE_FILE_NAME) + let PACKAGE_CACHE_FILE_PATH_PREVIEW () = + Path.Combine(PACKAGE_CACHE_FOLDER_PREVIEW(), PACKAGE_CACHE_FILE_NAME) + .Replace("\\", "/") + + let PACKAGE_CACHE_FILE_PATH_RELEASE () = + Path.Combine(PACKAGE_CACHE_FOLDER_RELEASE(), PACKAGE_CACHE_FILE_NAME) .Replace("\\", "/") let SERIALIZATION_OPTIONS = JsonSerializerOptions(WriteIndented = true) diff --git a/src/ARCValidationPackages/Domain.fs b/src/ARCValidationPackages/Domain.fs index 74a5b64..ba09532 100644 --- a/src/ARCValidationPackages/Domain.fs +++ b/src/ARCValidationPackages/Domain.fs @@ -41,7 +41,7 @@ type CachedValidationPackage = /// The input package index entry /// Optional. The date to set the CacheDate to. Defaults to the current date. static member ofPackageIndex (packageIndex: ValidationPackageIndex, ?Date: System.DateTimeOffset, ?CacheFolder: string) = - let path = defaultArg CacheFolder (Defaults.PACKAGE_CACHE_FOLDER()) + let path = defaultArg CacheFolder (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()) CachedValidationPackage.create( fileName = packageIndex.FileName, cacheDate = (defaultArg Date System.DateTimeOffset.Now), @@ -56,7 +56,7 @@ type CachedValidationPackage = /// /// static member ofPackageName (packageName: string, ?Date: System.DateTimeOffset, ?Path: string) = - let path = defaultArg Path (Defaults.PACKAGE_CACHE_FOLDER()) + let path = defaultArg Path (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()) CachedValidationPackage.create( fileName = packageName, cacheDate = (defaultArg Date System.DateTimeOffset.Now), diff --git a/src/ARCValidationPackages/PackageCache.fs b/src/ARCValidationPackages/PackageCache.fs index 08625d9..7653f45 100644 --- a/src/ARCValidationPackages/PackageCache.fs +++ b/src/ARCValidationPackages/PackageCache.fs @@ -146,18 +146,18 @@ type PackageCache = cache static member exists (?Path: string) = - let path = defaultArg Path (Defaults.PACKAGE_CACHE_FILE_PATH()) + let path = defaultArg Path (Defaults.PACKAGE_CACHE_FILE_PATH_PREVIEW()) File.Exists(path) static member read (?Path: string) = - let path = defaultArg Path (Defaults.PACKAGE_CACHE_FILE_PATH()) + let path = defaultArg Path (Defaults.PACKAGE_CACHE_FILE_PATH_PREVIEW()) path |> File.ReadAllText |> fun jsonString -> JsonSerializer.Deserialize(jsonString, Defaults.SERIALIZATION_OPTIONS) static member get (?Folder: string, ?FileName: string) = let fileName = defaultArg FileName (Defaults.PACKAGE_CACHE_FILE_NAME) - let folder = defaultArg Folder (Defaults.PACKAGE_CACHE_FOLDER()) + let folder = defaultArg Folder (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()) let path = Path.Combine(folder, fileName) if PackageCache.exists(path) then PackageCache.read(path) @@ -167,7 +167,7 @@ type PackageCache = static member write (?Folder: string, ?FileName: string) = fun (cache: PackageCache) -> let fileName = defaultArg FileName (Defaults.PACKAGE_CACHE_FILE_NAME) - let folder = defaultArg Folder (Defaults.PACKAGE_CACHE_FOLDER()) + let folder = defaultArg Folder (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()) let path = Path.Combine(folder, fileName) System.IO.FileInfo(path).Directory.Create(); // ensures directory exists JsonSerializer.Serialize(cache, Defaults.SERIALIZATION_OPTIONS) diff --git a/src/ARCValidationPackages/TopLevelAPI.fs b/src/ARCValidationPackages/TopLevelAPI.fs index c0e16d9..3c34763 100644 --- a/src/ARCValidationPackages/TopLevelAPI.fs +++ b/src/ARCValidationPackages/TopLevelAPI.fs @@ -1,5 +1,6 @@ namespace ARCValidationPackages open System.IO +open AVPRIndex open AVPRIndex.Domain type APIError = diff --git a/tests/ARCValidationPackages.Tests/ConfigTests.fs b/tests/ARCValidationPackages.Tests/ConfigTests.fs index ff36856..fb5c7ba 100644 --- a/tests/ARCValidationPackages.Tests/ConfigTests.fs +++ b/tests/ARCValidationPackages.Tests/ConfigTests.fs @@ -19,7 +19,7 @@ let ``Config tests`` = packageIndex = testPackageIndex, indexLastUpdated = testDate1, configFilePath = Defaults.CONFIG_FILE_PATH(), - packageCacheFolder = Defaults.PACKAGE_CACHE_FOLDER() + packageCacheFolder = Defaults.PACKAGE_CACHE_FOLDER_PREVIEW() ) test "config file path is correct" { @@ -31,7 +31,7 @@ let ``Config tests`` = test "package cache folder is correct" { Expect.equal (testConfig.PackageCacheFolder) - expected_package_cache_folder_path + expected_package_cache_folder_path_preview "package cache folder path is not correct" } test "config folder path is correct" { diff --git a/tests/ARCValidationPackages.Tests/DefaultsTests.fs b/tests/ARCValidationPackages.Tests/DefaultsTests.fs index 6035ebe..5962da8 100644 --- a/tests/ARCValidationPackages.Tests/DefaultsTests.fs +++ b/tests/ARCValidationPackages.Tests/DefaultsTests.fs @@ -33,19 +33,19 @@ let ``Defaults tests`` = } test "package cache folder path is correct" { Expect.equal - (Defaults.PACKAGE_CACHE_FOLDER()) - expected_package_cache_folder_path + (Defaults.PACKAGE_CACHE_FOLDER_PREVIEW()) + expected_package_cache_folder_path_preview "package cache folder path is not correct" } test "package cache folder path exists" { Expect.isTrue - (Directory.Exists(expected_package_cache_folder_path)) + (Directory.Exists(expected_package_cache_folder_path_preview)) "package cache folder path does not exist" } test "package cache file path is correct" { Expect.equal - (Defaults.PACKAGE_CACHE_FILE_PATH()) - expected_package_cache_file_path + (Defaults.PACKAGE_CACHE_FILE_PATH_PREVIEW()) + expected_package_cache_file_path_preview "config file path is not correct" } diff --git a/tests/ARCValidationPackages.Tests/PackageCacheTests.fs b/tests/ARCValidationPackages.Tests/PackageCacheTests.fs index 7bba3ed..83d4612 100644 --- a/tests/ARCValidationPackages.Tests/PackageCacheTests.fs +++ b/tests/ARCValidationPackages.Tests/PackageCacheTests.fs @@ -64,7 +64,7 @@ let tests = test "can write json" { deleteDefaultPackageCache() // make sure any cached file is deleted before testing that it can be written testPackageCache1 |> PackageCache.write() - Expect.isTrue (File.Exists(expected_package_cache_file_path)) "package cache file was not created" + Expect.isTrue (File.Exists(expected_package_cache_file_path_preview)) "package cache file was not created" } |> testSequenced test "can read json" { diff --git a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs index 4b9dcf3..cf43435 100644 --- a/tests/ARCValidationPackages.Tests/ReferenceObjects.fs +++ b/tests/ARCValidationPackages.Tests/ReferenceObjects.fs @@ -58,7 +58,7 @@ let testValidationPackage1 = CachedValidationPackage.create( "test@1.0.0.fsx", testDate1, - (Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx").Replace("\\","/")), + (Path.Combine(expected_package_cache_folder_path_preview, "test@1.0.0.fsx").Replace("\\","/")), ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", "this package is here for testing purposes only.", 1, 0, 0) ) @@ -66,7 +66,7 @@ let testValidationPackage2 = CachedValidationPackage.create( "test@1.0.0.fsx", testDate2, - (Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx").Replace("\\","/")), + (Path.Combine(expected_package_cache_folder_path_preview, "test@1.0.0.fsx").Replace("\\","/")), ValidationPackageMetadata.create("test", "this package is here for testing purposes only.", "this package is here for testing purposes only.", 1, 0, 0) ) @@ -74,7 +74,7 @@ let testValidationPackage3FullMetadata = CachedValidationPackage.create( "test@3.0.0.fsx", testDate3, - (Path.Combine(expected_package_cache_folder_path, "test@3.0.0.fsx").Replace("\\","/")), + (Path.Combine(expected_package_cache_folder_path_preview, "test@3.0.0.fsx").Replace("\\","/")), ValidationPackageMetadata.create( "test", "this package is here for testing purposes only.", diff --git a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs index c56eea7..effa922 100644 --- a/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs +++ b/tests/ARCValidationPackages.Tests/TopLevelAPITests.fs @@ -28,7 +28,7 @@ let ``Toplevel API tests`` = "Fresh package cache folder", fun (freshConfig, _) -> - Expect.equal freshConfig.PackageCacheFolder expected_package_cache_folder_path "package cache folder path is not correct" + Expect.equal freshConfig.PackageCacheFolder expected_package_cache_folder_path_preview "package cache folder path is not correct" "Fresh config package index contains packages", fun (freshConfig, _) -> diff --git a/tests/Common/TestUtils.fs b/tests/Common/TestUtils.fs index 34b93bf..a19eaa2 100644 --- a/tests/Common/TestUtils.fs +++ b/tests/Common/TestUtils.fs @@ -20,8 +20,12 @@ module TestUtils = let expected_config_folder_path = Path.Combine(application_data_path, "nfdi4plants/arc-validate").Replace("\\", "/") let expected_config_file_path = Path.Combine(expected_config_folder_path, "validation-packages-config.json").Replace("\\", "/") - let expected_package_cache_folder_path = Path.Combine(expected_config_folder_path, "package-cache").Replace("\\", "/") - let expected_package_cache_file_path = Path.Combine(expected_package_cache_folder_path, "validation-packages-cache.json").Replace("\\", "/") + let expected_package_cache_folder_path_preview = Path.Combine(expected_config_folder_path, "package-cache-preview").Replace("\\", "/") + let expected_package_cache_file_path_preview = Path.Combine(expected_package_cache_folder_path_preview, "validation-packages-cache.json").Replace("\\", "/") + + let expected_package_cache_folder_path_release = Path.Combine(expected_config_folder_path, "package-cache-release").Replace("\\", "/") + let expected_package_cache_file_path_release = Path.Combine(expected_package_cache_folder_path_release, "validation-packages-cache.json").Replace("\\", "/") + let runTool (tool: string) (args: string []) = CreateProcess.fromRawCommand tool args @@ -32,13 +36,13 @@ module TestUtils = // remove any existing config folder for running tests if Directory.Exists(expected_config_folder_path) then Directory.Delete(expected_config_folder_path, true) - if Directory.Exists(expected_package_cache_folder_path) then Directory.Delete(expected_package_cache_folder_path, true) + if Directory.Exists(expected_package_cache_folder_path_preview) then Directory.Delete(expected_package_cache_folder_path_preview, true) // ensure that these file do not exist before running tests if File.Exists(expected_config_file_path) then File.Delete(expected_config_file_path) - if File.Exists(expected_package_cache_file_path) then File.Delete(expected_package_cache_file_path) + if File.Exists(expected_package_cache_file_path_preview) then File.Delete(expected_package_cache_file_path_preview) let deleteDefaultPackageCache() = - if File.Exists(expected_package_cache_file_path) then File.Delete(expected_package_cache_file_path) + if File.Exists(expected_package_cache_file_path_preview) then File.Delete(expected_package_cache_file_path_preview) let deleteDefaultConfig() = if File.Exists(expected_config_file_path) then File.Delete(expected_config_file_path) diff --git a/tests/arc-validate.Tests/CLITests/PackageCommandTests.fs b/tests/arc-validate.Tests/CLITests/PackageCommandTests.fs index 8dbe2e9..a29e9bc 100644 --- a/tests/arc-validate.Tests/CLITests/PackageCommandTests.fs +++ b/tests/arc-validate.Tests/CLITests/PackageCommandTests.fs @@ -44,15 +44,15 @@ let ``PackageCommand CLI Tests`` = "Exit code is 0" , fun tool args proc -> Expect.equal proc.ExitCode 0 (ErrorMessage.withProcessDiagnostics "incorrect exit code" proc tool args) "Cache folder exists" , - fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path}." tool args) + fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path_preview}." tool args) "Cache exists" , - fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path}." tool args) + fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path_preview}." tool args) "Package script exists" , - fun tool args proc -> Expect.isTrue (File.Exists(Path.Combine(expected_package_cache_folder_path, "test@1.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_preview, "test@1.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not installed at expected location." tool args) "Package script has correct content" , fun tool args proc -> Expect.equal - (File.ReadAllText(Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx")).ReplaceLineEndings()) + (File.ReadAllText(Path.Combine(expected_package_cache_folder_path_preview, "test@1.0.0.fsx")).ReplaceLineEndings()) test_package_script_content_v1 (ErrorMessage.withCLIDiagnostics $"Package script did not have correct content" tool args) ] @@ -82,11 +82,11 @@ let ``PackageCommand CLI Tests`` = "Exit code is 0" , fun tool args proc -> Expect.equal proc.ExitCode 0 (ErrorMessage.withProcessDiagnostics "incorrect exit code" proc tool args) "Cache folder still exists" , - fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path}." tool args) + fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path_preview}." tool args) "Cache still exists" , - fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path}." tool args) + fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path_preview}." tool args) "test package script does not exist anymore" , - fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path, "test@1.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not uninstalled at expected location." tool args) + fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path_preview, "test@1.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not uninstalled at expected location." tool args) ] ]) testSequenced (testList "list v1" [ @@ -114,15 +114,15 @@ let ``PackageCommand CLI Tests`` = "Exit code is 0" , fun tool args proc -> Expect.equal proc.ExitCode 0 (ErrorMessage.withProcessDiagnostics "incorrect exit code" proc tool args) "Cache folder exists" , - fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path}." tool args) + fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path_preview}." tool args) "Cache exists" , - fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path}." tool args) + fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path_preview}." tool args) "Package script exists" , - 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_preview, "test@2.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not installed at expected location." tool args) "Package script has correct content" , fun tool args proc -> Expect.equal - (File.ReadAllText(Path.Combine(expected_package_cache_folder_path, "test@2.0.0.fsx")).ReplaceLineEndings()) + (File.ReadAllText(Path.Combine(expected_package_cache_folder_path_preview, "test@2.0.0.fsx")).ReplaceLineEndings()) test_package_script_content_v2 (ErrorMessage.withCLIDiagnostics $"Package script did not have correct content" tool args) ] @@ -152,11 +152,11 @@ let ``PackageCommand CLI Tests`` = "Exit code is 0" , fun tool args proc -> Expect.equal proc.ExitCode 0 (ErrorMessage.withProcessDiagnostics "incorrect exit code" proc tool args) "Cache folder still exists" , - fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path}." tool args) + fun tool args proc -> Expect.isTrue (Directory.Exists(expected_package_cache_folder_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache folder was not created at {expected_package_cache_folder_path_preview}." tool args) "Cache still exists" , - fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path}." tool args) + fun tool args proc -> Expect.isTrue (File.Exists(expected_package_cache_file_path_preview)) (ErrorMessage.withCLIDiagnostics $"package cache was not created at {expected_package_cache_file_path_preview}." tool args) "test package script does not exist anymore" , - fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path, "test@2.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not uninstalled at expected location." tool args) + fun tool args proc -> Expect.isFalse (File.Exists(Path.Combine(expected_package_cache_folder_path_preview, "test@2.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics $"package file was not uninstalled at expected location." tool args) ] ]) testSequenced (testList "list v2" [ diff --git a/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs b/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs index de07d0b..858dbfc 100644 --- a/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs +++ b/tests/arc-validate.Tests/CLITests/ValidateCommandTests.fs @@ -26,7 +26,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_preview, "test@2.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args ) ] yield! testFixture (Fixtures.withToolExecution @@ -57,7 +57,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@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_preview, "test@3.0.0.fsx"))) (ErrorMessage.withCLIDiagnostics "package file was not installed at expected location" tool args ) ] yield! testFixture (Fixtures.withToolExecution