File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed
AmplifyTools/AmplifyXcode
Tests/AmplifyXcodeCoreTests/Commands Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,18 @@ enum CommandImportModelsTasks {
1313 args: CommandImportModels . TaskArgs ) -> AmplifyCommandTaskResult {
1414 let modelsPath = environment. path ( for: args. generatedModelsPath)
1515 guard environment. directoryExists ( atPath: modelsPath) else {
16- return . failure(
17- AmplifyCommandError (
18- . folderNotFound,
19- errorDescription: " Amplify generated models not found at \( modelsPath) " ,
20- recoverySuggestion: " Run amplify codegen models. " ) )
16+ do {
17+ _ = try environment. createDirectory ( atPath: args. generatedModelsPath)
18+ }
19+ catch {
20+ return . failure(
21+ AmplifyCommandError (
22+ . folderNotFound,
23+ errorDescription: " Unable to create a new folder for models at path: \( modelsPath) " ,
24+ recoverySuggestion: " Run amplify codegen models. " ) )
25+ }
26+
27+ return . success( " Amplify models folder created at \( modelsPath) " )
2128 }
2229
2330 return . success( " Amplify models folder found at \( modelsPath) " )
Original file line number Diff line number Diff line change @@ -89,6 +89,8 @@ extension CommandEnvironment {
8989 if xcodeProjFiles. count != 1 {
9090 throw AmplifyCommandError (
9191 . xcodeProject,
92+ errorDescription: " Unable to find an Xcode project (i.e. `xcodeproj` file) in directory: \( path) " ,
93+ recoverySuggestion: " Please create a new Xcode project or import one at \( path) . " ,
9294 error: XcodeProjectError . notFound ( path: path) )
9395 }
9496 let projectName = xcodeProjFiles [ 0 ]
Original file line number Diff line number Diff line change @@ -61,12 +61,19 @@ class CommandImportModelsTasksTests: XCTestCase {
6161 _ = super. directoryExists ( atPath: dirPath)
6262 return false
6363 }
64+
65+ override func createDirectory( atPath path: String ) throws -> String {
66+ _ = try super. createDirectory ( atPath: path)
67+ return " created "
68+ }
6469 }
6570 let environment = FailingEnvironment ( basePath: basePath, fileManager: fileManager)
6671 let result = CommandImportModelsTasks . projectHasGeneratedModels ( environment: environment, args: taskArgs)
67- if case . success = result {
72+ guard case . success( let message ) = result else {
6873 XCTFail ( " projectHasGeneratedModels should not have succeeded " )
74+ return
6975 }
76+ XCTAssertTrue ( message. hasPrefix ( " Amplify models folder created at " ) )
7077 }
7178
7279}
You can’t perform that action at this time.
0 commit comments