Skip to content

Commit

Permalink
refactor:apply unit tests and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Marsyew committed Oct 29, 2024
1 parent fec3995 commit 6a53657
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions libs/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,7 @@ pub fn get_codec_type(codec: &RTCRtpCodecCapability) -> RTPCodecType {

pub fn create_child(command: Option<String>) -> Result<Option<Mutex<Child>>> {
let child = if let Some(command) = command {
let command = if cfg!(windows) {
command.replace('\\', "/")
} else {
command
};

let command = command.replace('\\', "/");
let mut args = shellwords::split(&command)?;

Some(Mutex::new(
Expand Down
4 changes: 2 additions & 2 deletions livetwo/src/whep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn from(
Some(Host::Domain(_)) | Some(Host::Ipv4(_)) => Ipv4Addr::UNSPECIFIED.to_string(),
Some(Host::Ipv6(_)) => Ipv6Addr::UNSPECIFIED.to_string(),

Check warning on line 64 in livetwo/src/whep.rs

View check run for this annotation

Codecov / codecov/patch

livetwo/src/whep.rs#L64

Added line #L64 was not covered by tests
None => {
eprintln!("Invalid host for {}, using default.", input);
error!("Invalid host for {}, using default.", input);
Ipv4Addr::UNSPECIFIED.to_string()

Check warning on line 67 in livetwo/src/whep.rs

View check run for this annotation

Codecov / codecov/patch

livetwo/src/whep.rs#L67

Added line #L67 was not covered by tests
}
};
Expand Down Expand Up @@ -141,7 +141,7 @@ pub async fn from(
.connection_information
.and_then(|conn_info| conn_info.address)
.map(|address| address.to_string())

Check warning on line 143 in livetwo/src/whep.rs

View check run for this annotation

Codecov / codecov/patch

livetwo/src/whep.rs#L142-L143

Added lines #L142 - L143 were not covered by tests
.unwrap_or("127.0.0.1".to_string());
.unwrap_or(Ipv4Addr::LOCALHOST.to_string());
for media in &mut session.media_descriptions {
if media.media_name.media == "video" {
if let Some(port) = media_info.video_rtp_client {
Expand Down
2 changes: 0 additions & 2 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ async fn test_liveion_stream_create() {
assert_eq!(1, body.len());
}

#[cfg(not(windows))]
#[tokio::test]
async fn test_liveion_stream_connect() {
let cfg = liveion::config::Config::default();
Expand Down Expand Up @@ -208,7 +207,6 @@ a=rtpmap:96 VP8/90000
assert!(result.is_some());
}

#[cfg(not(windows))]
#[tokio::test]
async fn test_liveion_stream_ffmpeg() {
let cfg = liveion::config::Config::default();
Expand Down

0 comments on commit 6a53657

Please sign in to comment.