Skip to content

Commit

Permalink
Use more informative feild name (md5 vs digest)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm committed Jan 31, 2024
1 parent 87ec644 commit 2c94503
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions R/export_portfolio.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
),
Expand Down
4 changes: 2 additions & 2 deletions R/reexport_portfolio.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
)

Expand Down
8 changes: 4 additions & 4 deletions inst/extdata/schema/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}$"
Expand Down Expand Up @@ -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}$"
Expand All @@ -64,7 +64,7 @@
},
"required": [
"output_filename",
"output_digest",
"output_md5",
"output_rows"
]
}
Expand All @@ -86,7 +86,7 @@
},
"required": [
"input_filename",
"input_digest",
"input_md5",
"portfolios"
]
}
Expand Down
12 changes: 6 additions & 6 deletions tests/testthat/helper-simple_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -93,7 +93,7 @@ expect_simple_reexport <- function(
object = names(metadata),
expected = c(
"group_cols",
"input_digest",
"input_md5",
"input_entries",
"input_filename",
"portfolios",
Expand All @@ -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)

Expand Down Expand Up @@ -138,7 +138,7 @@ expect_simple_reexport <- function(
required_fields <- c(
"output_filename",
"output_rows",
"output_digest"
"output_md5"
)
optional_fields <- c(
"investor_name",
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 2c94503

Please sign in to comment.