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:
40
app/models/testrun_message.rb
Normal file
40
app/models/testrun_message.rb
Normal 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
|
Reference in New Issue
Block a user