Renamed the Path+Functions extension in the library target as PathProvider.
This commit is contained in:
@@ -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"
|
||||
]}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user