Skip to content

Commit

Permalink
fix some quoting issues, improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
haberdashPI committed Sep 12, 2024
1 parent b6522fa commit 9fbdaac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/schemas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ function _generate_record_type_definitions(schema_version::SchemaVersion, record
# tried to implement the warning for empty arguments by defining `$R()` we would
# be defining the same method twice.
function $R(flag::$Legolas.CheckArgsFlag=$Legolas.CheckArgs(); $(field_kwargs...))
$(result) = $Legolas._check_empty_args(flag, $string(R), $(keys(record_fields)...))
$(result) = $Legolas._check_empty_args(flag, $(string(R)), $(keys(record_fields)...))
$((:($key = $(result)[$i]) for (i, key) in enumerate(keys(record_fields)))...)
$parent_record_application
$(field_assignments...)
Expand Down
10 changes: 9 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ end
a::Integer = replace(a, ' ' => '-')
end

@version FieldErrorV4 begin
x::Union{String,Missing}
end

@testset "Legolas record constructor error handling" begin
@testset "field constructor error" begin
ex_stack = try
Expand Down Expand Up @@ -772,12 +776,16 @@ end
end

@testset "appropriate warnings with zero-argument constructor" begin
msg = r"no arguments passed.*FieldErrorV1.*are you sure.*FieldErrorV1SchemaVersion"i
msg = r"no arguments passed.*FieldErrorV.*are you sure.*FieldErrorV(1|4)SchemaVersion"i

@test_logs (:warn, msg) FieldErrorV1()
@test_logs FieldErrorV1(; a=missing)
@test_logs FieldErrorV1((;))

@test_logs (:warn, msg) FieldErrorV4()
@test_logs FieldErrorV4(; x=missing)
@test_logs FieldErrorV4((;))

@test_logs (:warn, msg) begin
@test_throws ArgumentError FieldErrorV1{String,Int}()
end
Expand Down

0 comments on commit 9fbdaac

Please sign in to comment.