Skip to content

Commit

Permalink
fix(amplify-xcode): Fixing errors during amplify pull (#3536)
Browse files Browse the repository at this point in the history
* fix(amplify-xcode): Fixing quick start project errors

* updating errors names
  • Loading branch information
harsh62 authored Feb 23, 2024
1 parent 5ddf98c commit f9877c0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ enum CommandImportModelsTasks {
args: CommandImportModels.TaskArgs) -> AmplifyCommandTaskResult {
let modelsPath = environment.path(for: args.generatedModelsPath)
guard environment.directoryExists(atPath: modelsPath) else {
return .failure(
AmplifyCommandError(
.folderNotFound,
errorDescription: "Amplify generated models not found at \(modelsPath)",
recoverySuggestion: "Run amplify codegen models."))
do {
_ = try environment.createDirectory(atPath: args.generatedModelsPath)
}
catch {
return .failure(
AmplifyCommandError(
.folderNotFound,
errorDescription: "Unable to create a new folder for models at path: \(modelsPath)",
recoverySuggestion: "Run amplify codegen models."))
}

return .success("Amplify models folder created at \(modelsPath)")
}

return .success("Amplify models folder found at \(modelsPath)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ extension CommandEnvironment {
if xcodeProjFiles.count != 1 {
throw AmplifyCommandError(
.xcodeProject,
errorDescription: "Unable to find an Xcode project (i.e. `xcodeproj` file) in directory: \(path)",
recoverySuggestion: "Please create a new Xcode project or import one at \(path).",
error: XcodeProjectError.notFound(path: path))
}
let projectName = xcodeProjFiles[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ class CommandImportModelsTasksTests: XCTestCase {
_ = super.directoryExists(atPath: dirPath)
return false
}

override func createDirectory(atPath path: String) throws -> String {
_ = try super.createDirectory(atPath: path)
return "created"
}
}
let environment = FailingEnvironment(basePath: basePath, fileManager: fileManager)
let result = CommandImportModelsTasks.projectHasGeneratedModels(environment: environment, args: taskArgs)
if case .success = result {
guard case .success(let message) = result else {
XCTFail("projectHasGeneratedModels should not have succeeded")
return
}
XCTAssertTrue(message.hasPrefix("Amplify models folder created at"))
}

}

0 comments on commit f9877c0

Please sign in to comment.