Skip to content

Commit

Permalink
Extra test to check argument errors in main
Browse files Browse the repository at this point in the history
  • Loading branch information
deltamarnix committed Dec 19, 2023
1 parent 17d1003 commit f76c381
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/test/main_test.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@testitem "version" begin
using IOCapture: capture
using Logging: global_logger, ConsoleLogger

(; value, output) = capture() do
Ribasim.main(["--version"])
Expand All @@ -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")
Expand All @@ -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

0 comments on commit f76c381

Please sign in to comment.