this repo has no description
at main 59 lines 1.6 kB view raw
1use assert_matches::assert_matches; 2 3use browser_stream::rtmp::{RtmpError, build_output}; 4 5#[test] 6fn builds_output_from_split_fields() { 7 let output = build_output( 8 None, 9 Some("rtmp://live.example.com/app".to_string()), 10 Some("streamkey123".to_string()), 11 ) 12 .expect("build should succeed"); 13 14 assert_eq!(output, "rtmp://live.example.com/app/streamkey123"); 15} 16 17#[test] 18fn trims_slashes_and_spaces_in_stream_key() { 19 let output = build_output( 20 None, 21 Some("rtmp://live.example.com/app/".to_string()), 22 Some(" /abc123 ".to_string()), 23 ) 24 .expect("build should succeed"); 25 26 assert_eq!(output, "rtmp://live.example.com/app/abc123"); 27} 28 29#[test] 30fn output_flag_takes_precedence() { 31 let output = build_output( 32 Some("rtmps://primary.example.com/live/final".to_string()), 33 Some("rtmp://secondary.example.com/app".to_string()), 34 Some("secondary".to_string()), 35 ) 36 .expect("build should succeed"); 37 38 assert_eq!(output, "rtmps://primary.example.com/live/final"); 39} 40 41#[test] 42fn rejects_invalid_scheme() { 43 let err = build_output(Some("https://example.com/not-rtmp".to_string()), None, None) 44 .expect_err("should fail"); 45 46 assert_matches!(err, RtmpError::InvalidScheme(s) if s == "https"); 47} 48 49#[test] 50fn rejects_empty_key() { 51 let err = build_output( 52 None, 53 Some("rtmp://live.example.com/app".to_string()), 54 Some(" / ".to_string()), 55 ) 56 .expect_err("should fail"); 57 58 assert_matches!(err, RtmpError::EmptyStreamKey); 59}