JuliaTesting / ReferenceTests.jl

Utility package for comparing data against reference files
https://juliatesting.github.io/ReferenceTests.jl/latest/
Other
82 stars 14 forks source link

rename _convert to maybe_encode #64

Closed johnnychen94 closed 4 years ago

johnnychen94 commented 4 years ago

This is a sub PR of #61

Changes:


I'm unclear what should maybe_encode(format"TXT", df::DataFrame) and maybe_encode(format"SHA256", df::DataFrame) behave. The current behavior is maybe_encode(fmt, string(df))

Converting it using string can be prune to show changes. Hence I suggest we do something like

function maybe_encode(::Type{DataFormat{:TXT}}, df::DataFrame)
    save("tmp.csv", df)
    _ignore_crlf(read(String, "tmp.csv"))
end

function maybe_encode(::Type{DataFormat{:SHA256}}, df::DataFrame)
    save("tmp.csv", df)
    bytes2hex(sha256(read("tmp.csv")))
end

@oxinabox if you like this idea, I can make a PR for this change.

johnnychen94 commented 4 years ago

I'm merging this to avoid possible conflict and save myself some efforts from rebasing.

If there're any further comments, I'll address them in future PRs.