From 53c9899db6b06107da247457546ad0219ad985ba Mon Sep 17 00:00:00 2001 From: David Trattnig <david@subsquare.at> Date: Tue, 2 Aug 2022 13:34:19 +0200 Subject: [PATCH] test: test case to clear queue #116 --- tests/test_queue_clear.liq | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/test_queue_clear.liq diff --git a/tests/test_queue_clear.liq b/tests/test_queue_clear.liq new file mode 100644 index 0000000..f5463c8 --- /dev/null +++ b/tests/test_queue_clear.liq @@ -0,0 +1,49 @@ +#!/usr/bin/env liquidsoap +# +# Aura Engine (https://gitlab.servus.at/aura/engine) +# +# Copyright (C) 2017-now() - The Aura Engine Team. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +%include "base_config.liq" + + +def clear_queue(s) = + q = s.queue() + s.set_queue([]) + list.iter(request.destroy, q) +end + + +# 1.) Create queue and add requests +q = request.queue(id="q") +r = request.create("assets/audio.mp3") +q.push(r) +q.push(r) +q.push(r) + +# 2.) Check queue length +len = list.length(q.queue()) +print("QUEUE LENGTH: #{len}") +assertEquals(3, len) + +# 3.) Clear queue +clear_queue(q) + +# 4.) Check queue length +len = list.length(q.queue()) +print("QUEUE LENGTH: #{len}") +assertEquals(0, len) -- GitLab