Implemented the Outdated subcommand (#6)
This PR contains the work done to implement the `Outdated` subcommand that check for outdated package dependencies in a *Hummingbird* project. Reviewed-on: #6 Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #6.
This commit is contained in:
@@ -24,8 +24,8 @@ struct URL_ExtensionsTests {
|
||||
|
||||
// MARK: Computed tests
|
||||
|
||||
@Test(arguments: zip([URL.someFile, .dotFile, .tildeFile, .someURL],
|
||||
[String.someFilePath, .dotPath, .tildePath, .empty]))
|
||||
@Test(arguments: zip([URL.someFile, .dotFile, .tildeFile, .someEncodedFile, .someURL],
|
||||
[String.someFilePath, .dotPath, .tildePath, .someEncodedPath, .empty]))
|
||||
func pathString(
|
||||
with url: URL,
|
||||
expects path: String
|
||||
@@ -63,6 +63,7 @@ private extension String {
|
||||
static let dotPath = "."
|
||||
static let empty = ""
|
||||
static let tildePath = "~"
|
||||
static let someEncodedPath = "/sömê/páth/fîlê"
|
||||
static let someFilePath = "/some/file/path"
|
||||
}
|
||||
|
||||
@@ -70,6 +71,7 @@ private extension String {
|
||||
|
||||
private extension URL {
|
||||
static let dotFile = URL(at: .dotPath)
|
||||
static let someEncodedFile = URL(at: "/sömê/páth/fîlê")
|
||||
static let someFile = URL(at: .someFilePath)
|
||||
static let someURL = URL(string: "https://some.url.path")!
|
||||
static let tildeFile = URL(at: .tildePath)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import ColibriLibrary
|
||||
|
||||
struct OutdatedDependenciesTaskTests {
|
||||
|
||||
@Test(arguments: [nil, URL.someCurrentFolder])
|
||||
func task(at location: URL?) async throws {
|
||||
// GIVEN
|
||||
let terminalService = TerminalServiceSpy()
|
||||
let task = OutdatedDependenciesTask(terminalService: terminalService)
|
||||
|
||||
// WHEN
|
||||
try await task(at: location)
|
||||
|
||||
// THEN
|
||||
let executableURL = URL(at: "/usr/bin/swift")
|
||||
let arguments = if let location {
|
||||
["package", "update", "--package-path", location.pathString, "--dry-run"]
|
||||
} else {
|
||||
["package", "update", "--dry-run"]
|
||||
}
|
||||
|
||||
#expect(terminalService.actions.count == 1)
|
||||
#expect(terminalService.actions[0] == .ran(executableURL, arguments))
|
||||
}
|
||||
|
||||
@Test(arguments: [nil, URL.someCurrentFolder], [TerminalServiceError.unexpected, .output(""), .captured("")])
|
||||
func task(at location: URL?, throws error: TerminalServiceError) async throws {
|
||||
// GIVEN
|
||||
let terminalService = TerminalServiceMock(action: .error(error))
|
||||
let task = BuildProjectTask(terminalService: terminalService)
|
||||
|
||||
// WHEN
|
||||
// THEN
|
||||
await #expect(throws: error) {
|
||||
try await task(at: location)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user