require 'spec_helper'
require 'debci/oldest_job'
require 'debci/job'

describe Debci::OldestJob do
  let(:package) { Debci::Package.create!(name: 'mypkg') }
  let(:theuser) { Debci::User.create!(username: 'debci') }

  def create_job(**data)
    Debci::Job.create!(
      package: package,
      suite: 'unstable',
      arch: Debci.config.arch,
      requestor: theuser,
      **data,
    )
  end

  after(:each) do
    Debci::JobLatency.reset!
  end

  it 'gets oldest job per arch' do
    create_job(date: '2026-05-01 00:00', status: 'pass')
    create_job(date: '2026-05-02 00:00', status: nil)
  end
end
