Skip to content
Snippets Groups Projects
Commit 204590ae authored by David Trattnig's avatar David Trattnig
Browse files

Test: Actual func call and new assert feature

parent 29319bdc
No related branches found
No related tags found
1 merge request!3Liquidsoap 2 migration
...@@ -22,66 +22,21 @@ ...@@ -22,66 +22,21 @@
# Init defaults # Init defaults
engine_default_track_type = "0" engine_default_track_type = "0"
engine_current_track_type = ref("-1")
%include "../src/functions.liq"
# Evaluates the track type based on the given:
# a.) "meta.track_type" passed as annotation, and if not available on
# b.) "engine_current_track_type" passed via server function
# c.) "meta.source" and if not available on
# d.) configured default track type setting
#
# Returns:
# 0=QUEUE/FILE, 1=STREAM, 2=LIVE ANALOG, 3=PLAYLIST
#
def eval_track_type(meta_track_type, meta_source) =
# let source = meta["source"]
type_mapping = [
("fallback_folder", "0"),
("fallback_playlist", "3"),
("in_filesystem_0", "0"),
("in_filesystem_0", "0"),
("in_http_0", "1"),
("in_http_1", "1"),
("linein_0", "2"),
("linein_1", "2"),
("linein_2", "2"),
("linein_3", "2"),
("linein_4", "2")
]
if meta_track_type != "" then ### TEST ###
engine_current_track_type := meta_track_type
else
if !engine_current_track_type == "" then
let source_type = list.assoc(
default=engine_default_track_type,
meta_source,
type_mapping
)
engine_current_track_type := source_type
end
end
!engine_current_track_type
end
# Case 1: Passed meta track type => 33 # Case 1: Passed meta track type => 33
engine_current_track_type := "55"
type = eval_track_type("33", "fallback_playlist") type = eval_track_type("33", "fallback_playlist")
print("Got Type: #{type}") assertEquals(type, "33")
# Case 2: Passed track type via server function => 55
engine_current_track_type := "55"
type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}")
# Case 3: Detect track type via source => 3 # Case 2: Detect track type via source => 3
engine_current_track_type := ""
type = eval_track_type("", "fallback_playlist") type = eval_track_type("", "fallback_playlist")
print("Got Type: #{type}") assertEquals(type, "3")
# Case 4: Default track type => 0 # Case 3: Default track type => 0
engine_current_track_type := "" type = eval_track_type("", "not_existing_source")
type = eval_track_type("", "fallback_playlistx") assertEquals(type, "0")
print("Got Type: #{type}")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment