Implemented the "path" property for the Folder enumeration in the library target.
This commit is contained in:
parent
504b3be447
commit
720ad687fb
@ -1,10 +1,29 @@
|
|||||||
enum Folder: String {
|
enum Folder {
|
||||||
case app = "App/Sources"
|
case app
|
||||||
case libraryPublic = "Library/Sources/Public"
|
case libraryPublic
|
||||||
case libraryInternal = "Library/Sources/Internal"
|
case libraryInternal
|
||||||
case testCasesPublic = "Test/Sources/Cases/Public"
|
case testCasesPublic
|
||||||
case testCasesInternal = "Test/Sources/Cases/Internal"
|
case testCasesInternal
|
||||||
case testHelpers = "Test/Sources/Helpers"
|
case testHelpers
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Properties
|
||||||
|
|
||||||
|
extension Folder {
|
||||||
|
|
||||||
|
// MARK: Computed
|
||||||
|
|
||||||
|
var path: String {
|
||||||
|
switch self {
|
||||||
|
case .app: "App/Sources"
|
||||||
|
case .libraryPublic: "Library/Sources/Public"
|
||||||
|
case .libraryInternal: "Library/Sources/Internal"
|
||||||
|
case .testCasesPublic: "Test/Sources/Cases/Public"
|
||||||
|
case .testCasesInternal: "Test/Sources/Cases/Internal"
|
||||||
|
case .testHelpers: "Test/Sources/Helpers"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - CaseIterable
|
// MARK: - CaseIterable
|
||||||
|
@ -15,7 +15,7 @@ public struct CreateFoldersTask {
|
|||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
public func callAsFunction(at rootFolder: URL) async throws {
|
public func callAsFunction(at rootFolder: URL) async throws {
|
||||||
let folders = Folder.allCases.map { rootFolder.appendingPath($0.rawValue) }
|
let folders = Folder.allCases.map { rootFolder.appendingPath($0.path) }
|
||||||
|
|
||||||
for folder in folders {
|
for folder in folders {
|
||||||
try await fileService.createFolder(at: folder)
|
try await fileService.createFolder(at: folder)
|
||||||
|
34
Test/Sources/Cases/Internal/Enumerations/FolderTests.swift
Normal file
34
Test/Sources/Cases/Internal/Enumerations/FolderTests.swift
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import Testing
|
||||||
|
|
||||||
|
@testable import ColibriLibrary
|
||||||
|
|
||||||
|
struct FolderTests {
|
||||||
|
|
||||||
|
// MARK: Properties tests
|
||||||
|
|
||||||
|
@Test(arguments: zip(Folder.allCases, Expectation.paths))
|
||||||
|
func paths(for folder: Folder, expects path: String) async throws {
|
||||||
|
// GIVEN
|
||||||
|
// WHEN
|
||||||
|
let result = folder.path
|
||||||
|
|
||||||
|
// THEN
|
||||||
|
#expect(result == path)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Expectations
|
||||||
|
|
||||||
|
private extension FolderTests {
|
||||||
|
enum Expectation {
|
||||||
|
static let paths: [String] = [
|
||||||
|
"App/Sources",
|
||||||
|
"Library/Sources/Public",
|
||||||
|
"Library/Sources/Internal",
|
||||||
|
"Test/Sources/Cases/Public",
|
||||||
|
"Test/Sources/Cases/Internal",
|
||||||
|
"Test/Sources/Helpers"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,7 @@ struct CreateFoldersTaskTests {
|
|||||||
@Test(arguments: [URL.someCurrentFolder, .someDotFolder, .someTildeFolder])
|
@Test(arguments: [URL.someCurrentFolder, .someDotFolder, .someTildeFolder])
|
||||||
func createFolders(with rootFolder: URL) async throws {
|
func createFolders(with rootFolder: URL) async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let folders = Folder.allCases.map { rootFolder.appendingPath($0.rawValue) }
|
let folders = Folder.allCases.map { rootFolder.appendingPath($0.path) }
|
||||||
let actions = folders.map { FileServiceMock.Action.createFolder($0) }
|
let actions = folders.map { FileServiceMock.Action.createFolder($0) }
|
||||||
|
|
||||||
let createFolders = task(actions: actions)
|
let createFolders = task(actions: actions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user