Removed the "app", "appTests", and "package" cases from the File enumeration in the library target.
This commit is contained in:
parent
91762b18cd
commit
af73e6d1a2
@ -1,20 +0,0 @@
|
||||
import AppLibrary
|
||||
import ArgumentParser
|
||||
|
||||
@main
|
||||
struct App: AsyncParsableCommand {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@OptionGroup var options: Options
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
mutating func run() async throws {
|
||||
let builder = AppBuilder(name: "App")
|
||||
let app = try await builder(options)
|
||||
|
||||
try await app.runService()
|
||||
}
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
// swift-tools-version:6.0
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "App",
|
||||
platforms: [
|
||||
.macOS(.v14)
|
||||
],
|
||||
products: [
|
||||
.executable(name: "App", targets: ["App"]),
|
||||
.library(name: "AppLibrary", targets: ["AppLibrary"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
|
||||
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0")
|
||||
],
|
||||
targets: [
|
||||
.executableTarget(
|
||||
name: "App",
|
||||
dependencies: [
|
||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||
.product(name: "Hummingbird", package: "hummingbird"),
|
||||
.target(name: "AppLibrary")
|
||||
],
|
||||
path: "App"
|
||||
),
|
||||
.target(
|
||||
name: "AppLibrary",
|
||||
dependencies: [
|
||||
.product(name: "ArgumentParser", package: "swift-argument-parser"),
|
||||
.product(name: "Hummingbird", package: "hummingbird")
|
||||
],
|
||||
path: "Library"
|
||||
),
|
||||
.testTarget(
|
||||
name: "AppTests",
|
||||
dependencies: [
|
||||
.product(name: "HummingbirdTesting", package: "hummingbird"),
|
||||
.target(name: "AppLibrary")
|
||||
],
|
||||
path: "Test"
|
||||
)
|
||||
]
|
||||
)
|
@ -1,33 +0,0 @@
|
||||
import AppLibrary
|
||||
import Hummingbird
|
||||
import HummingbirdTesting
|
||||
import Testing
|
||||
|
||||
struct AppTests {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let arguments = TestArguments()
|
||||
private let builder = AppBuilder(name: "App")
|
||||
|
||||
// MARK: Route tests
|
||||
|
||||
@Test(arguments: ["/"])
|
||||
func routes(_ uri: String) async throws {
|
||||
let app = try await builder(arguments)
|
||||
|
||||
try await app.test(.router) { client in
|
||||
try await client.execute(uri: uri, method: .get) { response in
|
||||
#expect(response.status == .ok)
|
||||
#expect(response.body == .empty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: ByteBuffer+Constants
|
||||
|
||||
private extension ByteBuffer {
|
||||
static let empty = ByteBuffer(string: "")
|
||||
}
|
@ -1,16 +1,13 @@
|
||||
enum File: String {
|
||||
case app = "App"
|
||||
case appArguments = "AppArguments"
|
||||
case appBuilder = "AppBuilder"
|
||||
case appOptions = "AppOptions"
|
||||
case appTests = "AppTests"
|
||||
case dockerFile = "DockerFile"
|
||||
case dockerIgnore = "DockerIgnore"
|
||||
case environment = "Environment"
|
||||
case gitIgnore = "GitIgnore"
|
||||
case license = "License"
|
||||
case loggerLevel = "LoggerLevel"
|
||||
case package = "Package"
|
||||
case readme = "Readme"
|
||||
case testArguments = "TestArguments"
|
||||
|
||||
@ -24,11 +21,9 @@ extension File {
|
||||
|
||||
var fileName: String {
|
||||
switch self {
|
||||
case .app: "App.swift"
|
||||
case .appArguments: "AppArguments.swift"
|
||||
case .appBuilder: "AppBuilder.swift"
|
||||
case .appOptions: "AppOptions.swift"
|
||||
case .appTests: "AppTests.swift"
|
||||
case .dockerFile: "Dockerfile"
|
||||
case .dockerIgnore: ".dockerignore"
|
||||
case .environment: "Environment+Properties.swift"
|
||||
@ -36,7 +31,6 @@ extension File {
|
||||
case .license: "LICENSE"
|
||||
case .loggerLevel: "LoggerLevel+Conformances.swift"
|
||||
case .readme: "README.md"
|
||||
case .package: "Package.swift"
|
||||
case .testArguments: "TestArguments.swift"
|
||||
}
|
||||
}
|
||||
@ -47,9 +41,8 @@ extension File {
|
||||
|
||||
var folder: Folder {
|
||||
switch self {
|
||||
case .app, .appOptions: .app
|
||||
case .appOptions: .app
|
||||
case .appArguments, .appBuilder: .libraryPublic
|
||||
case .appTests: .testCasesPublic
|
||||
case .environment, .loggerLevel: .libraryInternal
|
||||
case .testArguments: .testHelpers
|
||||
default: .root
|
||||
@ -60,9 +53,9 @@ extension File {
|
||||
let basePath = "Resources/Files/Sources"
|
||||
|
||||
return switch self {
|
||||
case .app, .appOptions: "\(basePath)/App"
|
||||
case .appOptions: "\(basePath)/App"
|
||||
case .appArguments, .appBuilder, .environment, .loggerLevel: "\(basePath)/Library"
|
||||
case .appTests, .testArguments: "\(basePath)/Test"
|
||||
case .testArguments: "\(basePath)/Test"
|
||||
default: basePath
|
||||
}
|
||||
}
|
||||
|
@ -53,45 +53,37 @@ struct FileTests {
|
||||
private extension FileTests {
|
||||
enum Expectation {
|
||||
static let fileNames: [String] = [
|
||||
"App.swift",
|
||||
"AppArguments.swift",
|
||||
"AppBuilder.swift",
|
||||
"AppOptions.swift",
|
||||
"AppTests.swift",
|
||||
"Dockerfile",
|
||||
".dockerignore",
|
||||
"Environment+Properties.swift",
|
||||
".gitignore",
|
||||
"LICENSE",
|
||||
"LoggerLevel+Conformances.swift",
|
||||
"Package.swift",
|
||||
"README.md",
|
||||
"TestArguments.swift"
|
||||
]
|
||||
|
||||
static let filePaths: [String] = [
|
||||
"App/Sources/App.swift",
|
||||
"Library/Sources/Public/AppArguments.swift",
|
||||
"Library/Sources/Public/AppBuilder.swift",
|
||||
"App/Sources/AppOptions.swift",
|
||||
"Test/Sources/Cases/Public/AppTests.swift",
|
||||
"Dockerfile",
|
||||
".dockerignore",
|
||||
"Library/Sources/Internal/Environment+Properties.swift",
|
||||
".gitignore",
|
||||
"LICENSE",
|
||||
"Library/Sources/Internal/LoggerLevel+Conformances.swift",
|
||||
"Package.swift",
|
||||
"README.md",
|
||||
"Test/Sources/Helpers/TestArguments.swift"
|
||||
]
|
||||
|
||||
static let folders: [Folder] = [
|
||||
.app,
|
||||
.libraryPublic,
|
||||
.libraryPublic,
|
||||
.app,
|
||||
.testCasesPublic,
|
||||
.root,
|
||||
.root,
|
||||
.libraryInternal,
|
||||
@ -99,17 +91,13 @@ private extension FileTests {
|
||||
.root,
|
||||
.libraryInternal,
|
||||
.root,
|
||||
.root,
|
||||
.testHelpers
|
||||
]
|
||||
|
||||
|
||||
static let resourcePaths: [String] = [
|
||||
"Resources/Files/Sources/App",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources/App",
|
||||
"Resources/Files/Sources/Test",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Library",
|
||||
@ -117,9 +105,7 @@ private extension FileTests {
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Library",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources",
|
||||
"Resources/Files/Sources/Test"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
64
Test/Sources/Cases/Internal/Enumerations/TemplateTests.swift
Normal file
64
Test/Sources/Cases/Internal/Enumerations/TemplateTests.swift
Normal file
@ -0,0 +1,64 @@
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct TemplateTests {
|
||||
|
||||
// MARK: Properties tests
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.fileNames))
|
||||
func fileName(for template: Template, expects fileName: String) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.fileName
|
||||
|
||||
// THEN
|
||||
#expect(result == fileName)
|
||||
}
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.filePaths))
|
||||
func filePath(for template: Template, expects filePath: String) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.filePath
|
||||
|
||||
// THEN
|
||||
#expect(result == filePath)
|
||||
}
|
||||
|
||||
@Test(arguments: zip(Template.allCases, Expectation.folders))
|
||||
func folder(for template: Template, expects folder: Folder) async throws {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let result = template.folder
|
||||
|
||||
// THEN
|
||||
#expect(result == folder)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Expectations
|
||||
|
||||
private extension TemplateTests {
|
||||
enum Expectation {
|
||||
static let fileNames: [String] = [
|
||||
"App.swift",
|
||||
"AppTests.swift",
|
||||
"Package.swift",
|
||||
]
|
||||
|
||||
static let filePaths: [String] = [
|
||||
"App/Sources/App.swift",
|
||||
"Test/Sources/Cases/Public/AppTests.swift",
|
||||
"Package.swift",
|
||||
]
|
||||
|
||||
static let folders: [Folder] = [
|
||||
.app,
|
||||
.testCasesPublic,
|
||||
.root,
|
||||
]
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user