diff --git a/Meow/.swiftpm/xcode/xcshareddata/xcschemes/Meow.xcscheme b/Meow/.swiftpm/xcode/xcshareddata/xcschemes/Meow.xcscheme
index 6ff8bb1..fd2b43a 100644
--- a/Meow/.swiftpm/xcode/xcshareddata/xcschemes/Meow.xcscheme
+++ b/Meow/.swiftpm/xcode/xcshareddata/xcschemes/Meow.xcscheme
@@ -30,7 +30,7 @@
shouldUseLaunchSchemeArgsEnv = "YES">
diff --git a/Meow/Meow.xctestplan b/Meow/Meow.xctestplan
index ae8ba96..31062ff 100644
--- a/Meow/Meow.xctestplan
+++ b/Meow/Meow.xctestplan
@@ -14,7 +14,7 @@
"testTargets" : [
{
"target" : {
- "containerPath" : "container:Meow",
+ "containerPath" : "container:",
"identifier" : "MeowTests",
"name" : "MeowTests"
}
diff --git a/Meow/Package.swift b/Meow/Package.swift
index 3c48479..c4b93da 100644
--- a/Meow/Package.swift
+++ b/Meow/Package.swift
@@ -17,8 +17,8 @@ let package = Package(
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
- name: "Meow",
- targets: ["Meow"]
+ name: "CatFactsKit",
+ targets: ["CatFactsKit"]
),
],
dependencies: [
@@ -28,13 +28,13 @@ let package = Package(
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
- name: "Meow",
+ name: "CatFactsKit",
swiftSettings: commonSwiftSettings
),
.testTarget(
- name: "MeowTests",
+ name: "CatFactsKitTests",
dependencies: [
- "Meow",
+ "CatFactsKit",
"Mocker"
],
resources: [
diff --git a/Meow/Sources/Meow/Meow.swift b/Meow/Sources/CatFactsKit/CatFacts.swift
similarity index 80%
rename from Meow/Sources/Meow/Meow.swift
rename to Meow/Sources/CatFactsKit/CatFacts.swift
index f9a08dd..faa7608 100644
--- a/Meow/Sources/Meow/Meow.swift
+++ b/Meow/Sources/CatFactsKit/CatFacts.swift
@@ -1,11 +1,11 @@
//
-// Meow.swift
-// Meow
+// CatFacts.swift
+// CatFactsKit
//
import Foundation
-public struct Meow {
+public struct CatFacts {
let baseURL: URL
let urlSession: URLSession
@@ -25,7 +25,7 @@ public struct Meow {
private func generateRequest(path: String, params: [String: CustomStringConvertible] = [:]) throws -> URLRequest {
guard let url = URL(string: path, relativeTo: baseURL) else {
- throw MeowError.requestError("Couldn't generate URL from path: \(path), baseURL: \(baseURL)")
+ throw CatFactsError.requestError("Couldn't generate URL from path: \(path), baseURL: \(baseURL)")
}
let queryItems = params
@@ -39,11 +39,11 @@ public struct Meow {
private func decodeRequest(request: URLRequest) async throws -> T {
let (data, response) = try await urlSession.data(for: request)
guard let response = response as? HTTPURLResponse else {
- throw MeowError.connectionError("Couldn't get HTTP response from request \(request)")
+ throw CatFactsError.connectionError("Couldn't get HTTP response from request \(request)")
}
guard response.statusCode < 300 else {
let body = String(data: data, encoding: .utf8)
- throw MeowError.responseError(response.statusCode, body ?? "unknown error")
+ throw CatFactsError.responseError(response.statusCode, body ?? "unknown error")
}
return try JSONDecoder().decode(T.self, from: data)
}
diff --git a/Meow/Sources/Meow/MeowError.swift b/Meow/Sources/CatFactsKit/CatFactsError.swift
similarity index 60%
rename from Meow/Sources/Meow/MeowError.swift
rename to Meow/Sources/CatFactsKit/CatFactsError.swift
index 4db7cc7..b950e9b 100644
--- a/Meow/Sources/Meow/MeowError.swift
+++ b/Meow/Sources/CatFactsKit/CatFactsError.swift
@@ -1,11 +1,11 @@
//
-// MeowError.swift
-// Meow
+// CatFactsError.swift
+// CatFactsKit
//
import Foundation
-public enum MeowError: LocalizedError {
+public enum CatFactsError: LocalizedError {
case requestError(String)
case connectionError(String)
case responseError(Int, String)
diff --git a/Meow/Sources/Meow/FactsResponse.swift b/Meow/Sources/CatFactsKit/FactsResponse.swift
similarity index 86%
rename from Meow/Sources/Meow/FactsResponse.swift
rename to Meow/Sources/CatFactsKit/FactsResponse.swift
index 3e8ae97..62b7ea6 100644
--- a/Meow/Sources/Meow/FactsResponse.swift
+++ b/Meow/Sources/CatFactsKit/FactsResponse.swift
@@ -1,6 +1,6 @@
//
// FactsResponse.swift
-// Meow
+// CatFactsKit
//
import Foundation
diff --git a/Meow/Tests/MeowTests/MeowTests.swift b/Meow/Tests/CatFactsKitTests/CatFactsTests.swift
similarity index 84%
rename from Meow/Tests/MeowTests/MeowTests.swift
rename to Meow/Tests/CatFactsKitTests/CatFactsTests.swift
index 77729bc..2cdea12 100644
--- a/Meow/Tests/MeowTests/MeowTests.swift
+++ b/Meow/Tests/CatFactsKitTests/CatFactsTests.swift
@@ -6,10 +6,10 @@
import Foundation
import Testing
import Mocker
-@testable import Meow
+@testable import CatFactsKit
-@Suite("Meow Tests")
-struct MeowTests {
+@Suite("CatFacts Tests")
+struct CatFactsTests {
private let baseURL = URL(string: "https://meow.meow")!
let urlSession: URLSession = {
let configuration = URLSessionConfiguration.default
@@ -30,12 +30,13 @@ struct MeowTests {
mockPath("/", queryItems: ["count": count], data: [.get: Fixtures.facts])
let facts = try await instance.getFacts(count: count)
#expect(facts.count == count)
+ #expect(facts[3] == "The average cat food meal is the equivalent to about five mice.")
}
// MARK: - Private functionality
- private func vendInstance() -> Meow {
- return Meow(baseURL: baseURL, urlSession: urlSession)
+ private func vendInstance() -> CatFacts {
+ return CatFacts(baseURL: baseURL, urlSession: urlSession)
}
private func mockPath(_ path: String, headers: [String: String] = [:], queryItems: [String: CustomStringConvertible] = [:], data: [Mock.HTTPMethod: Data] = [:]) {
diff --git a/Meow/Tests/MeowTests/Fixtures.swift b/Meow/Tests/CatFactsKitTests/Fixtures.swift
similarity index 100%
rename from Meow/Tests/MeowTests/Fixtures.swift
rename to Meow/Tests/CatFactsKitTests/Fixtures.swift
diff --git a/Meow/Tests/MeowTests/Fixtures/facts.json b/Meow/Tests/CatFactsKitTests/Fixtures/facts.json
similarity index 100%
rename from Meow/Tests/MeowTests/Fixtures/facts.json
rename to Meow/Tests/CatFactsKitTests/Fixtures/facts.json