diff --git a/src/AVPRClient/AVPRClient.csproj b/src/AVPRClient/AVPRClient.csproj index 652ebfb..872ad7a 100644 --- a/src/AVPRClient/AVPRClient.csproj +++ b/src/AVPRClient/AVPRClient.csproj @@ -22,13 +22,13 @@ git $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md")) README.md - 0.0.8 + 0.0.9 - + diff --git a/src/AVPRClient/Extensions.cs b/src/AVPRClient/Extensions.cs index 303bd8c..87be033 100644 --- a/src/AVPRClient/Extensions.cs +++ b/src/AVPRClient/Extensions.cs @@ -26,7 +26,7 @@ DateTimeOffset releaseDate MajorVersion = indexedPackage.Metadata.MajorVersion, MinorVersion = indexedPackage.Metadata.MinorVersion, PatchVersion = indexedPackage.Metadata.PatchVersion, - PackageContent = File.ReadAllBytes(indexedPackage.RepoPath), + PackageContent = BinaryContent.fromFile(indexedPackage.RepoPath), ReleaseDate = releaseDate, Tags = indexedPackage.Metadata.Tags diff --git a/src/AVPRClient/RELEASE_NOTES.md b/src/AVPRClient/RELEASE_NOTES.md index 28685a7..7ea560a 100644 --- a/src/AVPRClient/RELEASE_NOTES.md +++ b/src/AVPRClient/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +## v0.0.9 +- Use AVPRIndex for all package binary content extractions + ## v0.0.8 - Use AVPRIndex for all package hash calculations diff --git a/tests/ClientTests/ReferenceObjects.fs b/tests/ClientTests/ReferenceObjects.fs index 002d899..1277dc4 100644 --- a/tests/ClientTests/ReferenceObjects.fs +++ b/tests/ClientTests/ReferenceObjects.fs @@ -73,20 +73,9 @@ module ValidationPackageMetadata = CQCHookEndpoint = "hookendpoint" ) -module PackageContentHash = - open System - open System.IO - open System.Text - open System.Security.Cryptography - - let expected_hash = - let md5 = MD5.Create() - "fixtures/test_validation_package_all_fields.fsx" - |> File.ReadAllText - |> fun s -> s.ReplaceLineEndings("\n") - |> Encoding.UTF8.GetBytes - |> md5.ComputeHash - |> Convert.ToHexString +module Hash = + + let expected_hash = "C5BD4262301D27CF667106D9024BD721" let allFields = AVPRClient.PackageContentHash( PackageName = "name", @@ -95,17 +84,42 @@ module PackageContentHash = PackagePatchVersion = 0, Hash = expected_hash ) - -module ValidationPackage = +module BinaryContent = open System.IO - let expected_content = + let expected_content = "(* +--- +Name: name +Summary: summary +Description = description +MajorVersion: 1 +MinorVersion: 0 +PatchVersion: 0 +Publish: true +Authors: + - FullName: test + Email: test@test.test + Affiliation: testaffiliation + AffiliationLink: test.com +Tags: + - Name: test + TermSourceREF: REF + TermAccessionNumber: TAN +ReleaseNotes: releasenotes +CQCHookEndpoint: hookendpoint +--- +*) + +printfn \"yes\"" .ReplaceLineEndings("\n") + + let expected_binary_content = expected_content |> System.Text.Encoding.UTF8.GetBytes - "fixtures/test_validation_package_all_fields.fsx" - |> File.ReadAllBytes +module ValidationPackage = + + open System.IO let allFields = AVPRClient.ValidationPackage( Name = "name", @@ -114,7 +128,7 @@ module ValidationPackage = MajorVersion = 1, MinorVersion = 0, PatchVersion = 0, - PackageContent = expected_content, + PackageContent = BinaryContent.expected_binary_content, ReleaseDate = date, Authors = [|Author.allFieldsClient|], Tags = [|OntologyAnnotation.allFieldsClient|], diff --git a/tests/ClientTests/TypeExtensionsTests.fs b/tests/ClientTests/TypeExtensionsTests.fs index 6dd298b..af1ee52 100644 --- a/tests/ClientTests/TypeExtensionsTests.fs +++ b/tests/ClientTests/TypeExtensionsTests.fs @@ -14,24 +14,26 @@ module ValidationPackageIndex = repoPath = "fixtures/test_validation_package_all_fields.fsx", fileName = "test_validation_package_all_fields.fsx", lastUpdated = ReferenceObjects.date, - contentHash = ReferenceObjects.PackageContentHash.expected_hash, + contentHash = ReferenceObjects.Hash.expected_hash, metadata = ReferenceObjects.ValidationPackageMetadata.allFields ) [] - let ``toValidationpackage with release date`` () = + let ``toValidationPackage with release date`` () = let actual = test_validation_package_all_fields.toValidationPackage(ReferenceObjects.date) Assert.Equivalent(actual, ReferenceObjects.ValidationPackage.allFields) + + [] let ``toPackageContentHash without direct file hash`` () = let actual = test_validation_package_all_fields.toPackageContentHash() - Assert.Equivalent(ReferenceObjects.PackageContentHash.allFields, actual) + Assert.Equivalent(ReferenceObjects.Hash.allFields, actual) [] let ``toPackageContentHash with direct file hash`` () = let actual = test_validation_package_all_fields.toPackageContentHash(HashFileDirectly = true) - Assert.Equivalent(ReferenceObjects.PackageContentHash.allFields, actual) + Assert.Equivalent(ReferenceObjects.Hash.allFields, actual) module Author =