Skip to content

Commit

Permalink
Added test about githubinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
bergel committed Mar 5, 2024
1 parent 444bdc8 commit 990cbfd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/rai_rules_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,45 @@ end
end
@test result_matching
end

@testset "Report generation of 1 file with no errors and github info" begin
local result_matching = false
mktempdir() do dir
file1 = joinpath(dir, "foo.jl")
open(file1, "w") do io1
write(io1, "function f()\n @spawn 1 + 1\nend\n")
flush(io1)

output_file = tempname()
json_io = IOBuffer()
StaticLint.generate_report(
[file1],
output_file,
json_io,
"RelationalAI/raicode",
"axb-foo-bar")

json_report = JSON3.read(String(take!(json_io)))
@test json_report[:source] == "StaticLint"
@test json_report[:data][:files_count] == 1
@test json_report[:data][:errors_count] == 0

local result
open(output_file) do oo
result = read(oo, String)
end

expected = r"""
## Static code analyzer report
\*\*Output of the \[StaticLint\.jl code analyzer\]\(https://github\.com/RelationalAI/StaticLint\.jl\)\*\*
Report creation time \(UTC\): \H+
🎉No potential threats are found over 1 Julia file.👍
"""
result_matching = !isnothing(match(expected, result))
end
end
@test result_matching
end
end

@testset "Running on a directory" begin
Expand Down

0 comments on commit 990cbfd

Please sign in to comment.