Skip to content

Commit

Permalink
Improves testing of ComputePackageVerificationCode() and ComputeFileC…
Browse files Browse the repository at this point in the history
…hecksum()
  • Loading branch information
SamuraiAku committed Jan 29, 2024
1 parent 71399f4 commit a4ba1ab
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Test
using JSON
using Dates
using TimeZones
using SHA

@testset "Bool check" begin
@test Bool(" True ")
Expand Down
9 changes: 8 additions & 1 deletion test/test_checksums.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
@testset "checksums" begin
verifcode= ComputePackageVerificationCode(pkgdir(SPDX), String["SPDX.spdx.json"], String[".git"])
@test verifcode isa SpdxPkgVerificationCodeV2 # No good way to indepently verify that the calculation is correct.
@test issubset(["SPDX.spdx.json"], verifcode.ExcludedFiles)

checksum= ComputeFileChecksum("SHA256", joinpath(pkgdir(SPDX), "Project.toml"))
@test checksum isa SpdxChecksumV2 # No good way to indepently verify that the calculation is correct.
@test checksum isa SpdxChecksumV2
@test checksum.Hash == open(joinpath(pkgdir(SPDX), "Project.toml")) do f
return bytes2hex(sha256(f))
end

linktest_code= ComputePackageVerificationCode(joinpath(pkgdir(SPDX), "test", "test_package"))
@test issetequal(linktest_code.ExcludedFiles, ["dir_link", "file_link", "src/bad_link"])
end
1 change: 1 addition & 0 deletions test/test_package/dir_link
1 change: 1 addition & 0 deletions test/test_package/file1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a file.
1 change: 1 addition & 0 deletions test/test_package/file2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is also a file
1 change: 1 addition & 0 deletions test/test_package/file_link
1 change: 1 addition & 0 deletions test/test_package/src/bad_link
1 change: 1 addition & 0 deletions test/test_package/src/file3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a file as well.

0 comments on commit a4ba1ab

Please sign in to comment.