Use TestrunMessages instead of Testrun.output when displaying output

This commit is contained in:
Sebastian Serth
2022-04-28 22:40:11 +02:00
parent db62686b75
commit 4ef7da839d
4 changed files with 11 additions and 17 deletions

View File

@@ -17,4 +17,8 @@ class Testrun < ApplicationRecord
validates :exit_code, numericality: {only_integer: true, min: 0, max: 255}, allow_nil: true
validates :status, presence: true
def log
testrun_messages.output.select(:log).map(&:log).join.presence
end
end

View File

@@ -33,6 +33,9 @@ class TestrunMessage < ApplicationRecord
validates :log, length: {minimum: 0, allow_nil: false}, if: -> { cmd_write? }
validate :either_data_or_log
default_scope { order(timestamp: :asc) }
scope :output, -> { where(cmd: 1, stream: %i[stdout stderr]) }
def self.create_for(testrun, messages)
# We don't want to store anything if the testrun passed
return if testrun.passed?