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 {
13
13
args: CommandImportModels . TaskArgs ) -> AmplifyCommandTaskResult {
14
14
let modelsPath = environment. path ( for: args. generatedModelsPath)
15
15
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) " )
21
28
}
22
29
23
30
return . success( " Amplify models folder found at \( modelsPath) " )
Original file line number Diff line number Diff line change @@ -89,6 +89,8 @@ extension CommandEnvironment {
89
89
if xcodeProjFiles. count != 1 {
90
90
throw AmplifyCommandError (
91
91
. 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) . " ,
92
94
error: XcodeProjectError . notFound ( path: path) )
93
95
}
94
96
let projectName = xcodeProjFiles [ 0 ]
Original file line number Diff line number Diff line change @@ -61,12 +61,19 @@ class CommandImportModelsTasksTests: XCTestCase {
61
61
_ = super. directoryExists ( atPath: dirPath)
62
62
return false
63
63
}
64
+
65
+ override func createDirectory( atPath path: String ) throws -> String {
66
+ _ = try super. createDirectory ( atPath: path)
67
+ return " created "
68
+ }
64
69
}
65
70
let environment = FailingEnvironment ( basePath: basePath, fileManager: fileManager)
66
71
let result = CommandImportModelsTasks . projectHasGeneratedModels ( environment: environment, args: taskArgs)
67
- if case . success = result {
72
+ guard case . success( let message ) = result else {
68
73
XCTFail ( " projectHasGeneratedModels should not have succeeded " )
74
+ return
69
75
}
76
+ XCTAssertTrue ( message. hasPrefix ( " Amplify models folder created at " ) )
70
77
}
71
78
72
79
}
You can’t perform that action at this time.
0 commit comments