From 2c945035aef8b723966a34cde291a029d0782163 Mon Sep 17 00:00:00 2001 From: Alex Axthelm Date: Wed, 31 Jan 2024 13:22:10 +0100 Subject: [PATCH] Use more informative feild name (md5 vs digest) --- R/export_portfolio.R | 4 ++-- R/reexport_portfolio.R | 4 ++-- inst/extdata/schema/metadata.json | 8 ++++---- tests/testthat/helper-simple_output.R | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/R/export_portfolio.R b/R/export_portfolio.R index 1fef115..47c5fbe 100644 --- a/R/export_portfolio.R +++ b/R/export_portfolio.R @@ -54,7 +54,7 @@ export_portfolio <- function( ) logger::log_debug("Portfolio data written to file: ", output_filepath) - output_digest <- digest::digest( + output_md5 <- digest::digest( object = output_filepath, file = TRUE, algo = "md5", @@ -64,7 +64,7 @@ export_portfolio <- function( portfolio_metadata <- c( list( - output_digest = output_digest, + output_md5 = output_md5, output_filename = output_filename, output_rows = output_rows ), diff --git a/R/reexport_portfolio.R b/R/reexport_portfolio.R index 99d9dfc..3523564 100644 --- a/R/reexport_portfolio.R +++ b/R/reexport_portfolio.R @@ -19,7 +19,7 @@ reexport_portfolio <- function( logger::log_debug("Portfolio data read.") logger::log_trace("Indentifying portfolio metadata.") - input_digest <- digest::digest( + input_md5 <- digest::digest( object = input_filepath, file = TRUE, algo = "md5", @@ -30,7 +30,7 @@ reexport_portfolio <- function( file_summary <- list( input_filename = input_filename, - input_digest = input_digest, + input_md5 = input_md5, system_info = get_system_info() ) diff --git a/inst/extdata/schema/metadata.json b/inst/extdata/schema/metadata.json index 01b64da..bcfce7e 100644 --- a/inst/extdata/schema/metadata.json +++ b/inst/extdata/schema/metadata.json @@ -12,7 +12,7 @@ "description": "Filename of the input file.", "type": "string" }, - "input_digest": { + "input_md5": { "description": "md5 filehash of input file.", "type": "string", "pattern": "^[a-f0-9]{32}$" @@ -43,7 +43,7 @@ "type": "string", "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[89ab][a-f0-9]{3}-[a-f0-9]{12}.csv$" }, - "output_digest": { + "output_md5": { "description": "md5 filehash of output file.", "type": "string", "pattern": "^[a-f0-9]{32}$" @@ -64,7 +64,7 @@ }, "required": [ "output_filename", - "output_digest", + "output_md5", "output_rows" ] } @@ -86,7 +86,7 @@ }, "required": [ "input_filename", - "input_digest", + "input_md5", "portfolios" ] } diff --git a/tests/testthat/helper-simple_output.R b/tests/testthat/helper-simple_output.R index 9a26c8c..600b718 100644 --- a/tests/testthat/helper-simple_output.R +++ b/tests/testthat/helper-simple_output.R @@ -57,7 +57,7 @@ expect_simple_export_portfolio <- function( metadata[["output_filename"]] ) # check metadata field names - required_fields <- c("output_filename", "output_rows", "output_digest") + required_fields <- c("output_filename", "output_rows", "output_md5") optional_fields <- c("investor_name", "portfolio_name") testthat::expect_contains(names(metadata), required_fields) testthat::expect_in( @@ -93,7 +93,7 @@ expect_simple_reexport <- function( object = names(metadata), expected = c( "group_cols", - "input_digest", + "input_md5", "input_entries", "input_filename", "portfolios", @@ -104,7 +104,7 @@ expect_simple_reexport <- function( testthat::expect_null(metadata[["errors"]]) testthat::expect_setequal(metadata[["group_cols"]], colnames(groups)) - testthat::expect_identical(metadata[["input_digest"]], input_digest) + testthat::expect_identical(metadata[["input_md5"]], input_digest) testthat::expect_identical(metadata[["input_entries"]], input_entries) testthat::expect_identical(metadata[["input_filename"]], input_filename) @@ -138,7 +138,7 @@ expect_simple_reexport <- function( required_fields <- c( "output_filename", "output_rows", - "output_digest" + "output_md5" ) optional_fields <- c( "investor_name", @@ -216,12 +216,12 @@ expect_reexport_failure <- function( object = names(metadata), expected = c( "errors", - "input_digest", + "input_md5", "input_filename", "system_info" ) ) - testthat::expect_identical(metadata[["input_digest"]], input_digest) + testthat::expect_identical(metadata[["input_md5"]], input_digest) testthat::expect_identical(metadata[["input_filename"]], input_filename) testthat::expect_type(metadata[["errors"]], "list") testthat::expect_identical(