Renamed the Path+Functions extension in the library target as PathProvider.

This commit is contained in:
2025-03-08 00:57:59 +01:00
parent 0ba84ca27a
commit 39a9523ac9
5 changed files with 153 additions and 50 deletions
@@ -0,0 +1,93 @@
import Testing
@testable import AppLibrary
@Suite("PathProvider", .tags(.provider))
struct PathProviderTests {
// MARK: Functions tests
@Test(arguments: zip([String].pathURLs, [String].nameArchives))
func archiveName(
from path: String,
expects name: String
) async throws {
// GIVEN
// WHEN
let result = PathProvider.archiveName(from: path)
// THEN
#expect(result == name)
}
@Test(arguments: zip([String].pathURLs, [String].pathArchives))
func archivePath(
from path: String,
expects archive: String
) async throws {
// GIVEN
// WHEN
let result = PathProvider.archivePath(from: path)
// THEN
#expect(result == archive)
}
@Test(arguments: zip([String].pathURLs, [String].pathResources))
func resourcePath(
from path: String,
expects resource: String
) async throws {
// GIVEN
// WHEN
let result = PathProvider.resourcePath(from: path)
// THEN
#expect(result == resource)
}
}
// MARK: - Collection+Strings
private extension Collection where Element == String {
// MARK: Properties
static var nameArchives: [Element] {[
.empty,
.empty,
.empty,
"somearchive",
"somearchive",
"somearchive"
]}
static var pathArchives: [Element] {[
.empty,
.empty,
.empty,
"/SomeArchive.doccarchive",
"/SomeArchive.doccarchive",
"/SomeArchive.doccarchive"
]}
static var pathResources: [Element] {[
.forwardSlash,
.forwardSlash,
.forwardSlash,
.forwardSlash,
.forwardSlash,
"/path/to/resource"
]}
static var pathURLs: [Element] {[
.empty,
"/archives",
"/archives/",
"/archives/SomeArchive",
"/archives/SomeArchive/",
"/archives/SomeArchive/path/to/resource"
]}
}