Tests: Fix old Id3v2Tag tests

This commit is contained in:
Serial 2023-10-01 10:47:16 -04:00 committed by Alex
parent 9554295e51
commit aa50837ecc
3 changed files with 12 additions and 8 deletions

View file

@ -159,8 +159,6 @@ impl Id3v2Tag {
impl Id3v2Tag { impl Id3v2Tag {
/// Gets a [`Frame`] from an id /// Gets a [`Frame`] from an id
///
/// NOTE: This is *not* case-sensitive
pub fn get(&self, id: &FrameId<'_>) -> Option<&Frame<'static>> { pub fn get(&self, id: &FrameId<'_>) -> Option<&Frame<'static>> {
self.frames.iter().find(|f| &f.id == id) self.frames.iter().find(|f| &f.id == id)
} }
@ -208,7 +206,7 @@ impl Id3v2Tag {
/// ///
/// tag.set_title(String::from("Foo\0Bar")); /// tag.set_title(String::from("Foo\0Bar"));
/// ///
/// let mut titles = tag.get_texts(&TITLE_ID); /// let mut titles = tag.get_texts(&TITLE_ID).expect("Should exist");
/// ///
/// assert_eq!(titles.next(), Some("Foo")); /// assert_eq!(titles.next(), Some("Foo"));
/// assert_eq!(titles.next(), Some("Bar")); /// assert_eq!(titles.next(), Some("Bar"));

View file

@ -1,6 +1,7 @@
use crate::{set_artist, temp_file, verify_artist}; use crate::{set_artist, temp_file, verify_artist};
use std::borrow::Cow;
use lofty::id3::v2::{Frame, FrameFlags, FrameValue, Id3v2Tag, KeyValueFrame}; use lofty::id3::v2::{Frame, FrameFlags, FrameId, FrameValue, Id3v2Tag, KeyValueFrame};
use lofty::mpeg::MpegFile; use lofty::mpeg::MpegFile;
use lofty::{ use lofty::{
Accessor, AudioFile, FileType, ItemKey, ItemValue, ParseOptions, Probe, Tag, TagExt, TagItem, Accessor, AudioFile, FileType, ItemKey, ItemValue, ParseOptions, Probe, Tag, TagExt, TagItem,
@ -344,7 +345,11 @@ fn read_and_write_tpil_frame() {
let tag: &Id3v2Tag = mpeg_file.id3v2().unwrap(); let tag: &Id3v2Tag = mpeg_file.id3v2().unwrap();
let content = match tag.get("TIPL").unwrap().content() { let content = match tag
.get(&FrameId::Valid(Cow::Borrowed("TIPL")))
.unwrap()
.content()
{
FrameValue::KeyValue(content) => content, FrameValue::KeyValue(content) => content,
_ => panic!("Wrong Frame Value Type for TIPL"), _ => panic!("Wrong Frame Value Type for TIPL"),
}; };

View file

@ -1,7 +1,8 @@
// Tests for special case conversions // Tests for special case conversions
use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, Id3v2Tag, UnsynchronizedTextFrame}; use lofty::id3::v2::{CommentFrame, Frame, FrameFlags, FrameId, Id3v2Tag, UnsynchronizedTextFrame};
use lofty::{ItemKey, Tag, TagType, TextEncoding}; use lofty::{ItemKey, Tag, TagType, TextEncoding};
use std::borrow::Cow;
#[test] #[test]
fn tag_to_id3v2_lang_frame() { fn tag_to_id3v2_lang_frame() {
@ -12,7 +13,7 @@ fn tag_to_id3v2_lang_frame() {
let id3: Id3v2Tag = tag.into(); let id3: Id3v2Tag = tag.into();
assert_eq!( assert_eq!(
id3.get("USLT"), id3.get(&FrameId::Valid(Cow::Borrowed("USLT"))),
Frame::new( Frame::new(
"USLT", "USLT",
UnsynchronizedTextFrame { UnsynchronizedTextFrame {
@ -28,7 +29,7 @@ fn tag_to_id3v2_lang_frame() {
); );
assert_eq!( assert_eq!(
id3.get("COMM"), id3.get(&FrameId::Valid(Cow::Borrowed("COMM"))),
Frame::new( Frame::new(
"COMM", "COMM",
CommentFrame { CommentFrame {