caesura 0.31.0

An all-in-one command line tool to transcode FLAC audio files and upload to gazelle based indexers/trackers
Documentation
use crate::testing_prelude::*;

#[tokio::test]
async fn spectrogram_command_flac16_441() {
    let album = AlbumConfig::with_format(SampleFormat::FLAC16_441);
    let snapshot = spectrogram_command_helper(album).await;
    let snapshot = normalize_snapshots!(snapshot);
    assert_yaml_snapshot!(snapshot);
}

#[tokio::test]
async fn spectrogram_command_flac16_48() {
    let album = AlbumConfig::with_format(SampleFormat::FLAC16_48);
    let snapshot = spectrogram_command_helper(album).await;
    let snapshot = normalize_snapshots!(snapshot);
    assert_yaml_snapshot!(snapshot);
}

/// Test zoom spectrogram for a 30-second track (shorter than the 60-second standard position).
/// Should capture at 50% mark instead.
#[tokio::test]
async fn spectrogram_command_track_30s() {
    let album = AlbumConfig::track_30s();
    let snapshot = spectrogram_command_helper(album).await;
    let snapshot = normalize_snapshots!(snapshot);
    assert_yaml_snapshot!(snapshot);
}

/// Test zoom spectrogram for a 1-second track (shorter than the 2-second capture window).
/// `SoX` should gracefully capture whatever audio exists.
#[tokio::test]
async fn spectrogram_command_track_1s() {
    let album = AlbumConfig::track_1s();
    let snapshot = spectrogram_command_helper(album).await;
    let snapshot = normalize_snapshots!(snapshot);
    assert_yaml_snapshot!(snapshot);
}

async fn spectrogram_command_helper(album: AlbumConfig) -> Vec<FileSnapshot> {
    // Arrange
    init_logger();
    let test_dir = TestDirectory::new();
    let album = AlbumProvider::get_advanced(album).await;
    let host = HostBuilder::new()
        .with_mock_api(album)
        .with_test_options(&test_dir)
        .await
        .expect_build();
    let provider = host.services.get_required::<SourceProvider>();
    let generator = host.services.get_required::<SpectrogramCommand>();
    let source = provider
        .get(AlbumConfig::TORRENT_ID)
        .await
        .expect("should not fail")
        .expect("should find source");

    // Act
    let result = generator.execute(&source).await;

    // Assert
    assert!(result.is_ok());
    DirectorySnapshot::new()
        .with_directory(test_dir.output())
        .create()
        .expect("should read output directory")
}