add debug output
This commit is contained in:
parent
85c9570b87
commit
a7128fa1b3
|
@ -9,12 +9,15 @@ module Travis::API::V3
|
|||
|
||||
raise EntityMissing, 'log not found'.freeze if log.nil?
|
||||
|
||||
#if the log exists and has not been archived yet, then collect the log_parts and return the Log query object
|
||||
p log.archived_at
|
||||
|
||||
#if the log has been archived, go to s3
|
||||
if log.archived_at
|
||||
## if it's not there then fetch it from S3, and return it wrapped as a compatible log_parts object with a hard coded #number (log_parts have a number) and the parts chunked (not sure how to do this)
|
||||
archived_log_path = archive_url("/jobs/#{params[:job.id]}/log.txt")
|
||||
p archived_log_path
|
||||
content = open(Net::HTTP.get(URI.parse(archived_log_path)))
|
||||
|
||||
p content
|
||||
log_parts = []
|
||||
|
||||
content.each_line.with_index do |line, number|
|
||||
|
|
|
@ -5,14 +5,17 @@ describe Travis::API::V3::Services::Log::Find, set_app: true do
|
|||
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: user.login, name: 'minimal').first }
|
||||
let(:build) { repo.builds.last }
|
||||
let(:job) { Travis::API::V3::Models::Build.find(build.id).jobs.last }
|
||||
let(:s3job) { Travis::API::V3::Models::Build.find(build.id).jobs.first }
|
||||
let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: 1) }
|
||||
let(:headers) { { 'HTTP_AUTHORIZATION' => "token #{token}" } }
|
||||
let(:parsed_body) { JSON.load(body) }
|
||||
let(:log) { job.log }
|
||||
let(:s3log) { s3job.log }
|
||||
# before { s3log.update_attribute(:archived_at, Time.now) }
|
||||
|
||||
|
||||
context 'when log stored in db' do
|
||||
describe 'returns the Log with an array of Log Parts' do
|
||||
let(:log) { job.log }
|
||||
|
||||
describe 'returns log with an array of Log Parts' do
|
||||
example do
|
||||
log_part = log.log_parts.create(content: "logging it", number: 0)
|
||||
get("/v3/job/#{job.id}/log", {}, headers)
|
||||
|
@ -29,11 +32,29 @@ describe Travis::API::V3::Services::Log::Find, set_app: true do
|
|||
"number" => log_part.number }])
|
||||
end
|
||||
end
|
||||
describe 'returns log as plain text'
|
||||
end
|
||||
|
||||
context 'when log not found in db but stored on S3' do
|
||||
describe 'returns log with an array of Log Parts' do
|
||||
example do
|
||||
s3log.update_attribute(:archived_at, Time.now)
|
||||
get("/v3/job/#{s3job.id}/log", {}, headers)
|
||||
p s3job
|
||||
p s3job.id
|
||||
p s3log
|
||||
p s3log.archived_at
|
||||
|
||||
expect(parsed_body).to eq(
|
||||
'@href' => "/v3/job/#{s3job.id}/log",
|
||||
'@representation' => 'standard',
|
||||
'@type' => 'log',
|
||||
'content' => 'minimal log 1',
|
||||
'id' => s3log.id,
|
||||
'log_parts' => [])
|
||||
end
|
||||
end
|
||||
describe 'returns log as plain text'
|
||||
describe 'returns log as chunked json'
|
||||
end
|
||||
|
||||
context 'when log not found anywhere' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user