Implemented the Update subcommand (#7)

This PR contains the work done to implement the `Update` subcommand that update the package dependencies in a *Hummingbird* project.

Reviewed-on: #7
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 #7.
This commit is contained in:
2025-02-19 00:14:00 +00:00
committed by Javier Cicchelli
parent 7ee071010d
commit ab5f589547
6 changed files with 67 additions and 17 deletions
@@ -3,23 +3,28 @@ import Testing
@testable import ColibriLibrary
struct OutdatedDependenciesTaskTests {
struct UpdateDependenciesTaskTests {
@Test(arguments: [nil, URL.someCurrentFolder])
func task(at location: URL?) async throws {
@Test(arguments: [nil, URL.someCurrentFolder], [false, true])
func task(at location: URL?, checkOutdated: Bool) async throws {
// GIVEN
let terminalService = TerminalServiceSpy()
let task = OutdatedDependenciesTask(terminalService: terminalService)
let task = UpdateDependenciesTask(terminalService: terminalService)
// WHEN
try await task(at: location)
try await task(at: location, checkOutdated: checkOutdated)
// THEN
let executableURL = URL(at: "/usr/bin/swift")
let arguments = if let location {
["package", "update", "--package-path", location.pathString, "--dry-run"]
var arguments = if let location {
["package", "update", "--package-path", location.pathString]
} else {
["package", "update", "--dry-run"]
["package", "update"]
}
if checkOutdated {
arguments.append("--dry-run")
}
#expect(terminalService.actions.count == 1)
@@ -30,12 +35,12 @@ struct OutdatedDependenciesTaskTests {
func task(at location: URL?, throws error: TerminalServiceError) async throws {
// GIVEN
let terminalService = TerminalServiceMock(action: .error(error))
let task = BuildProjectTask(terminalService: terminalService)
let task = UpdateDependenciesTask(terminalService: terminalService)
// WHEN
// THEN
await #expect(throws: error) {
try await task(at: location)
try await task(at: location, checkOutdated: .random())
}
}