From f76c381acabe7294d2bd2a2cc34eab4e2172a114 Mon Sep 17 00:00:00 2001 From: Marnix Kraus Date: Tue, 19 Dec 2023 17:52:41 +0100 Subject: [PATCH] Extra test to check argument errors in main --- core/test/main_test.jl | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/test/main_test.jl b/core/test/main_test.jl index 6a03b0a88..fd21a9537 100644 --- a/core/test/main_test.jl +++ b/core/test/main_test.jl @@ -1,6 +1,5 @@ @testitem "version" begin using IOCapture: capture - using Logging: global_logger, ConsoleLogger (; value, output) = capture() do Ribasim.main(["--version"]) @@ -11,7 +10,6 @@ end @testitem "toml_path" begin using IOCapture: capture - using Logging: global_logger, ConsoleLogger model_path = normpath(@__DIR__, "../../generated_testmodels/basic/") toml_path = normpath(model_path, "ribasim.toml") @@ -26,3 +24,23 @@ end @show backtrace end end + +@testitem "too many arguments for main" begin + using IOCapture: capture + + (; value, output) = capture() do + Ribasim.main(["too", "many"]) + end + @test value == 1 + @test occursin("Exactly 1 argument expected, got 2", output) +end + +@testitem "non-existing file for main" begin + using IOCapture: capture + + (; value, output) = capture() do + Ribasim.main(["non-existing-file.toml"]) + end + @test value == 1 + @test occursin("File not found: non-existing-file.toml", output) +end