Skip to content

Commit

Permalink
Added new test to achieve full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
clizbe committed Oct 18, 2023
1 parent 41233c8 commit e50a991
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ end
df = CSV.read(joinpath(dir, "bad-assets-data.csv"), DataFrame; header = 2)

# FIXME: instead of examples, mutate and test
# Example 1 - bad data, silent
col_err, col_type_err = TulipaEnergyModel.validate_df(
df,
TulipaEnergyModel.AssetData;
Expand All @@ -60,5 +61,13 @@ end
@test col_err == [:id]
@test col_type_err ==
[(:investable, Bool, String7), (:peak_demand, Float64, String7)]

# Example 2 - bad data, verbose
expected_error_message = "bad-assets-data.csv failed validation\n [1] missing columns: [:id]\n [2] incompatible column types:\n - investable::String7 (expected: Bool)\n - peak_demand::String7 (expected: Float64)"
@test_throws expected_error_message TulipaEnergyModel.validate_df(
df,
TulipaEnergyModel.AssetData;
fname = "bad-assets-data.csv",
)
end
end

0 comments on commit e50a991

Please sign in to comment.