Add exit_code and status to Testruns, create model for TestrunMessages

* This is the first step to migrate the `output` column from Testruns to a dedicated table TestrunMessages
This commit is contained in:
Sebastian Serth
2022-04-24 18:09:37 +02:00
parent 5f16792ee9
commit e9efb5bc2b
7 changed files with 146 additions and 25 deletions

View File

@ -0,0 +1,40 @@
# frozen_string_literal: true
class TestrunMessage < ApplicationRecord
belongs_to :testrun
enum cmd: {
input: 0,
write: 1,
clear: 2,
turtle: 3,
turtlebatch: 4,
render: 5,
exit: 6,
timeout: 7,
out_of_memory: 8,
status: 9,
hint: 10,
client_kill: 11,
exception: 12,
result: 13,
}, _default: :write, _prefix: true
enum stream: {
stdin: 0,
stdout: 1,
stderr: 2,
}, _prefix: true
validates :cmd, presence: true
validates :timestamp, presence: true
validate :either_data_or_log
def either_data_or_log
if [data, log].count(&:present?) > 1
errors.add(log, "can't be present if data is also present")
end
end
private :either_data_or_log
end