diff --git a/youtui/src/app.rs b/youtui/src/app.rs index c427f8f6..511986b3 100644 --- a/youtui/src/app.rs +++ b/youtui/src/app.rs @@ -217,16 +217,11 @@ fn destruct_terminal() -> Result<()> { /// # Panics /// If tracing fails to initialise, function will panic fn init_tracing(debug: bool) -> Result<()> { - // NOTE: It seems that tui-logger only displays events at info or higher, - // possibly a limitation with the implementation. - // https://github.com/gin66/tui-logger/issues/66 - // TODO: PR upstream let tui_logger_layer = tui_logger::tracing_subscriber_layer(); if debug { let log_file_name = get_data_dir()?.join(LOG_FILE_NAME); let log_file = std::fs::File::create(&log_file_name)?; let log_file_layer = tracing_subscriber::fmt::layer().with_writer(Arc::new(log_file)); - // TODO: Confirm if this filter is correct. let context_layer = tracing_subscriber::filter::Targets::new().with_target("youtui", tracing::Level::DEBUG); tracing_subscriber::registry() @@ -237,7 +232,6 @@ fn init_tracing(debug: bool) -> Result<()> { .expect("Expected logger to initialise succesfully"); info!("Started in debug mode, logging to {:?}.", log_file_name); } else { - // TODO: Confirm if this filter is correct. let context_layer = tracing_subscriber::filter::Targets::new().with_target("youtui", tracing::Level::INFO); tracing_subscriber::registry() diff --git a/youtui/src/config.rs b/youtui/src/config.rs index 664e230e..7306f5ef 100644 --- a/youtui/src/config.rs +++ b/youtui/src/config.rs @@ -95,38 +95,29 @@ impl Config { #[cfg(test)] mod tests { - use crate::{ - config::{keymap::YoutuiKeymap, Config, ConfigIR, CONFIG_FILE_NAME}, - get_config_dir, - }; + use crate::config::{keymap::YoutuiKeymap, Config, ConfigIR}; use pretty_assertions::assert_eq; + async fn example_config_file() -> String { + tokio::fs::read_to_string("./config/config.toml") + .await + .unwrap() + } + #[tokio::test] async fn test_deserialize_default_config_to_ir() { - let config_dir = get_config_dir().unwrap(); - let config_file_location = config_dir.join(CONFIG_FILE_NAME); - let config_file = tokio::fs::read_to_string(&config_file_location) - .await - .unwrap(); + let config_file = example_config_file().await; toml::from_str::(&config_file).unwrap(); } #[tokio::test] async fn test_convert_ir_to_config() { - let config_dir = get_config_dir().unwrap(); - let config_file_location = config_dir.join(CONFIG_FILE_NAME); - let config_file = tokio::fs::read_to_string(&config_file_location) - .await - .unwrap(); + let config_file = example_config_file().await; let ir: ConfigIR = toml::from_str(&config_file).unwrap(); Config::try_from(ir).unwrap(); } #[tokio::test] async fn test_default_config_equals_deserialized_config() { - let config_dir = get_config_dir().unwrap(); - let config_file_location = config_dir.join(CONFIG_FILE_NAME); - let config_file = tokio::fs::read_to_string(&config_file_location) - .await - .unwrap(); + let config_file = example_config_file().await; let ir: ConfigIR = toml::from_str(&config_file).unwrap(); let Config { auth_type, diff --git a/ytmapi-rs/tests/live_integration_tests.rs b/ytmapi-rs/tests/live_integration_tests.rs index ea31fe7d..99593e12 100644 --- a/ytmapi-rs/tests/live_integration_tests.rs +++ b/ytmapi-rs/tests/live_integration_tests.rs @@ -31,6 +31,7 @@ async fn test_get_oauth_code() { // NOTE: Internal only - due to use of error.is_oauth_expired() #[tokio::test] +#[ignore = "Oauth is broken https://github.com/nick42d/youtui/issues/179"] async fn test_expired_oauth() { // XXX: Assuming this error only occurs for expired headers. // This assumption may be incorrect. @@ -257,17 +258,7 @@ async fn test_get_mood_playlists() { .next() .unwrap(); let query = GetMoodPlaylistsQuery::new(first_mood_playlist.params); - let oauth_fut = async { - let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); - // Don't stuff around trying the keep the local OAuth secret up to - //date, just refresh it each time. - api.refresh_token().await.unwrap(); - api.query(query.clone()).await.unwrap(); - }; - let browser_fut = async { - browser_api.query(query.clone()).await.unwrap(); - }; - tokio::join!(oauth_fut, browser_fut); + browser_api.query(query.clone()).await.unwrap(); } #[ignore = "Ignored by default due to quota"] @@ -282,17 +273,7 @@ async fn test_get_library_upload_artist() { .next() .expect("To run this test, you will need to upload songs from at least one artist"); let query = GetLibraryUploadArtistQuery::new(first_artist.artist_id); - let oauth_fut = async { - let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); - // Don't stuff around trying the keep the local OAuth secret up to date, just - // refresh it each time. - api.refresh_token().await.unwrap(); - let _ = api.query(query.clone()).await.unwrap(); - }; - let browser_fut = async { - browser_api.query(query.clone()).await.unwrap(); - }; - tokio::join!(oauth_fut, browser_fut); + browser_api.query(query.clone()).await.unwrap(); } #[ignore = "Ignored by default due to quota"] @@ -307,17 +288,7 @@ async fn test_get_library_upload_album() { .next() .expect("To run this test, you will need to upload songs from at least one album"); let query = GetLibraryUploadAlbumQuery::new(first_album.album_id); - let oauth_fut = async { - let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); - // Don't stuff around trying the keep the local OAuth secret up to date, just - // refresh it each time. - api.refresh_token().await.unwrap(); - let _ = api.query(query.clone()).await.unwrap(); - }; - let browser_fut = async { - browser_api.query(query.clone()).await.unwrap(); - }; - tokio::join!(oauth_fut, browser_fut); + browser_api.query(query.clone()).await.unwrap(); } #[tokio::test] @@ -447,7 +418,7 @@ async fn test_add_remove_history_items() { } #[tokio::test] -#[ignore = "Ignored by default due to quota"] +#[ignore = "Ignored by default due to quota, also oauth is broken"] async fn test_delete_create_playlist_oauth() { let mut api = new_standard_oauth_api().await.unwrap(); // Don't stuff around trying the keep the local OAuth secret up to date, just @@ -642,6 +613,7 @@ async fn test_edit_playlist() { // # BASIC TESTS WITH ADDITIONAL ASSERTIONS #[tokio::test] +#[ignore = "Oauth is broken https://github.com/nick42d/youtui/issues/179"] async fn test_get_library_playlists_oauth() { let mut api = new_standard_oauth_api().await.unwrap(); // Don't stuff around trying the keep the local OAuth secret up to date, just @@ -657,6 +629,7 @@ async fn test_get_library_playlists() { assert!(!res.playlists.is_empty()); } #[tokio::test] +#[ignore = "Oauth is broken https://github.com/nick42d/youtui/issues/179"] async fn test_get_library_artists_oauth() { let mut api = new_standard_oauth_api().await.unwrap(); // Don't stuff around trying the keep the local OAuth secret up to date, just diff --git a/ytmapi-rs/tests/utils/mod.rs b/ytmapi-rs/tests/utils/mod.rs index cd3916a4..b40d3dcd 100644 --- a/ytmapi-rs/tests/utils/mod.rs +++ b/ytmapi-rs/tests/utils/mod.rs @@ -56,22 +56,30 @@ macro_rules! generate_query_test { $fname:ident,$query:expr) => { #[tokio::test] async fn $fname() { - let oauth_future = async { - let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); - // Don't stuff around trying the keep the local OAuth secret up to date, just - // refresh it each time. - api.refresh_token().await.unwrap(); - api.query($query) - .await - .expect("Expected query to run succesfully under oauth"); - }; - let browser_auth_future = async { - let api = crate::utils::new_standard_api().await.unwrap(); - api.query($query) - .await - .expect("Expected query to run succesfully under browser auth"); - }; - tokio::join!(oauth_future, browser_auth_future); + // NOTE: Code to handle Oath and Browser tests commented out due to oauth + // issues. + // + // https://github.com/nick42d/youtui/issues/179 + // let oauth_future = async { + // let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); + // // Don't stuff around trying the keep the local OAuth secret up to date, + // just // refresh it each time. + // api.refresh_token().await.unwrap(); + // api.query($query) + // .await + // .expect("Expected query to run succesfully under oauth"); + // }; + // let browser_auth_future = async { + // let api = crate::utils::new_standard_api().await.unwrap(); + // api.query($query) + // .await + // .expect("Expected query to run succesfully under browser auth"); + // }; + // tokio::join!(oauth_future, browser_auth_future); + let api = crate::utils::new_standard_api().await.unwrap(); + api.query($query) + .await + .expect("Expected query to run succesfully under browser auth"); } }; } @@ -85,33 +93,47 @@ macro_rules! generate_stream_test { $fname:ident,$query:expr) => { #[tokio::test] async fn $fname() { + // NOTE: Code to handle Oath and Browser tests commented out due to oauth + // issues. + // + // https://github.com/nick42d/youtui/issues/179 use futures::stream::{StreamExt, TryStreamExt}; - let oauth_future = async { - let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); - // Don't stuff around trying the keep the local OAuth secret up to date, just - // refresh it each time. - api.refresh_token().await.unwrap(); - let query = $query; - let stream = api.stream(&query); - tokio::pin!(stream); - stream - .try_collect::>() - .await - .expect("Expected all results from oauth stream to suceed"); - }; - let browser_auth_future = async { - let api = crate::utils::new_standard_api().await.unwrap(); - let query = $query; - let stream = api.stream(&query); - tokio::pin!(stream); - stream - // limit test to 5 results to avoid overload - .take(5) - .try_collect::>() - .await - .expect("Expected all results from browser stream to suceed"); - }; - tokio::join!(oauth_future, browser_auth_future); + // let oauth_future = async { + // let mut api = crate::utils::new_standard_oauth_api().await.unwrap(); + // // Don't stuff around trying the keep the local OAuth secret up to date, + // just // refresh it each time. + // api.refresh_token().await.unwrap(); + // let query = $query; + // let stream = api.stream(&query); + // tokio::pin!(stream); + // stream + // .try_collect::>() + // .await + // .expect("Expected all results from oauth stream to suceed"); + // }; + // let browser_auth_future = async { + // let api = crate::utils::new_standard_api().await.unwrap(); + // let query = $query; + // let stream = api.stream(&query); + // tokio::pin!(stream); + // stream + // // limit test to 5 results to avoid overload + // .take(5) + // .try_collect::>() + // .await + // .expect("Expected all results from browser stream to suceed"); + // }; + // tokio::join!(oauth_future, browser_auth_future); + let api = crate::utils::new_standard_api().await.unwrap(); + let query = $query; + let stream = api.stream(&query); + tokio::pin!(stream); + stream + // limit test to 5 results to avoid overload + .take(5) + .try_collect::>() + .await + .expect("Expected all results from browser stream to suceed"); } }; }