Skip to content

Commit

Permalink
Add tests to verify gracefully handling missing job files (#6343)
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
ErikSchierboom authored Oct 18, 2023
1 parent 098b762 commit 1850e51
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/commands/submission/analysis/process_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,30 @@ class Submission::Analysis::ProcessTest < ActiveSupport::TestCase
job = create_analyzer_job!(submission, execution_status: 200, data:)
Submission::Analysis::Process.(job)
end

test "gracefully handle tags.json not being there" do
submission = create :submission
ops_status = 200
comments = [{ 'foo' => 'bar' }]
data = { 'comments' => comments }
execution_output = {
"analysis.json" => data&.to_json
}
job = create_tooling_job!(
submission,
:analyzer,
execution_status: ops_status,
execution_output:
)

Bugsnag.expects(:notify).never

Submission::Analysis::Process.(job)

analysis = submission.reload.analysis
assert_equal job.id, analysis.tooling_job_id
assert_equal ops_status, analysis.ops_status
assert_equal data, analysis.send(:data)
assert_equal ({}), analysis.send(:tags_data)
end
end
35 changes: 35 additions & 0 deletions test/commands/submission/representation/process_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,39 @@ class Submission::Representation::ProcessTest < ActiveSupport::TestCase
representation = Exercise::Representation.last
assert_equal 2, representation.exercise_version
end

test "gracefully handle representation.json not being there" do
ops_status = 200
ast = "my ast"
ast_digest = Submission::Representation.digest_ast(ast)
submission = create :submission
mapping = { 'foo' => 'bar' }

Bugsnag.expects(:notify).never

job = create_representer_job!(submission, execution_status: ops_status, ast:, mapping:)

execution_output = {
"representation.txt" => ast,
"mapping.json" => mapping.to_json
}
create_tooling_job!(
submission,
:representer,
execution_status: 200,
execution_output:,
context: { reason: nil },
source: {
'exercise_git_sha' => submission.git_sha
}
)

Submission::Representation::Process.(job)

representation = submission.reload.submission_representation

assert_equal job.id, representation.tooling_job_id
assert_equal ops_status, representation.ops_status
assert_equal ast_digest, representation.ast_digest
end
end

0 comments on commit 1850e51

Please sign in to comment.