-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fabian Zwick
committed
Oct 18, 2024
1 parent
3df669b
commit c00a7c7
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Mp3FileWriterTest.swift | ||
// ID3TagEditor | ||
// | ||
// Created by Fabian Zwick on 18.10.24. | ||
// | ||
|
||
import Foundation | ||
import Testing | ||
|
||
@testable import ID3TagEditor | ||
|
||
struct Mp3FileWriterTest { | ||
@Test func testWritingWithCurrentTag() throws { | ||
let newTag = ID32v3TagBuilder() | ||
.title(frame: .init(content: "Test Title")) | ||
.album(frame: .init(content: "Test Album")) | ||
.build() | ||
|
||
let id3TagCreator = ID3TagCreatorFactory.make() | ||
let newId3TagData = try id3TagCreator.create(id3Tag: newTag) | ||
|
||
let fromPath = PathLoader().pathFor(name: "example", fileType: "mp3") | ||
let currentId3Tag = try ID3TagEditor().read(from: fromPath) | ||
|
||
let pathMp3Generated = NSHomeDirectory() + "/testWritingWithCurrentTagAndEqualToPath.mp3" | ||
#expect(throws: Never.self) { try Mp3FileWriter().write(newId3TagData: newId3TagData, currentId3Tag: currentId3Tag, fromPath: fromPath, toPath: pathMp3Generated) } | ||
|
||
let readTag = try ID3TagEditor().read(from: pathMp3Generated) | ||
#expect((readTag?.frames[.title] as? ID3FrameWithStringContent)?.content == "Test Title") | ||
#expect((readTag?.frames[.album] as? ID3FrameWithStringContent)?.content == "Test Album") | ||
} | ||
|
||
static let allTests = [ | ||
("testWritingWithCurrentTag", testWritingWithCurrentTag) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters