Files
MatchLiveTv/backend/spec/services/youtube/broadcast_service_spec.rb
Emiliano Frascaro 2c5f4f82eb YouTube live immediata: relay sempre attivo e attivazione broadcast.
Il relay parte dal job overlay ogni 2s; scheduledStartTime ~90s invece di 5 min;
transition testing/live quando l'ingest RTMP raggiunge YouTube.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 08:19:20 +02:00

31 lines
1.0 KiB
Ruby

require "rails_helper"
RSpec.describe Youtube::BroadcastService do
describe "#normalize_scheduled_start_time" do
subject(:service) { described_class.allocate }
it "usa tra ~90 secondi se scheduled_at è assente" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
t = service.send(:normalize_scheduled_start_time, nil)
expect(t).to eq(Time.utc(2026, 6, 3, 20, 1, 30))
end
end
it "sposta nel futuro se scheduled_at è nel passato" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
past = Time.zone.parse("2026-06-03 10:00:00")
t = service.send(:normalize_scheduled_start_time, past)
expect(t).to eq(Time.utc(2026, 6, 3, 20, 1, 30))
end
end
it "mantiene scheduled_at se è nel futuro entro 7 giorni" do
travel_to Time.zone.parse("2026-06-03 20:00:00 UTC") do
future = Time.zone.parse("2026-06-05 18:00:00")
t = service.send(:normalize_scheduled_start_time, future)
expect(t).to eq(future.utc)
end
end
end
end