Skip to content

Commit 4cc294a

Browse files
committed
add unit test for deployment descriptor builder
1 parent 4fa3873 commit 4cc294a

File tree

8 files changed

+1044
-824
lines changed

8 files changed

+1044
-824
lines changed

Examples/SAM/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ build:
44
update:
55
swift package update
66

7-
test:
7+
testlambda:
88
swift test
99

10+
test:
11+
(cd ../.. && swift test --filter AWSLambdaDeploymentDescriptor)
12+
1013
release:
1114
swift build -c release
1215

Plugins/AWSLambdaDeployer/Plugin.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ struct AWSLambdaPackager: CommandPlugin {
6060
stackName : configuration.stackName,
6161
verboseLogging: configuration.verboseLogging)
6262
}
63-
64-
// list endpoints
63+
64+
// list endpoints
6565
if !configuration.noList {
6666
let output = try self.listEndpoints(samExecutablePath: samExecutablePath,
6767
samDeploymentDescriptorFilePath: samDeploymentDescriptorFilePath,
@@ -223,11 +223,11 @@ struct AWSLambdaPackager: CommandPlugin {
223223
throw DeployerPluginError.error(error)
224224
} catch let error as Utils.ProcessError {
225225
if case .processFailed(_, let errorCode, let output) = error {
226-
if errorCode == 1 && output.contains("Error: No changes to deploy.") {
227-
print("There is no changes to deploy.")
226+
if errorCode == 1 && output.contains("Error: No changes to deploy.") {
227+
print("There is no changes to deploy.")
228228
} else {
229229
print("ProcessError : \(error)")
230-
throw DeployerPluginError.error(error)
230+
throw DeployerPluginError.error(error)
231231
}
232232
}
233233
} catch {
@@ -237,9 +237,9 @@ struct AWSLambdaPackager: CommandPlugin {
237237
}
238238

239239
private func listEndpoints(samExecutablePath: Path,
240-
samDeploymentDescriptorFilePath: String,
241-
stackName: String,
242-
verboseLogging: Bool) throws -> String {
240+
samDeploymentDescriptorFilePath: String,
241+
stackName: String,
242+
verboseLogging: Bool) throws -> String {
243243

244244
//TODO: check if there is a samconfig.toml file.
245245
// when there is no file, generate one with default data or data collected from params
@@ -251,18 +251,18 @@ struct AWSLambdaPackager: CommandPlugin {
251251
do {
252252

253253
return try Utils.execute(
254-
executable: samExecutablePath,
255-
arguments: ["list", "endpoints",
256-
"-t", samDeploymentDescriptorFilePath,
257-
"--stack-name", stackName,
258-
"--output", "json"],
259-
logLevel: verboseLogging ? .debug : .silent)
254+
executable: samExecutablePath,
255+
arguments: ["list", "endpoints",
256+
"-t", samDeploymentDescriptorFilePath,
257+
"--stack-name", stackName,
258+
"--output", "json"],
259+
logLevel: verboseLogging ? .debug : .silent)
260260
} catch {
261261
print("Unexpected error : \(error)")
262262
throw DeployerPluginError.error(error)
263263
}
264264
}
265-
265+
266266
private func displayHelpMessage() {
267267
print("""
268268
OVERVIEW: A swift plugin to deploy your Lambda function on your AWS account.
@@ -326,8 +326,8 @@ private struct Configuration: CustomStringConvertible {
326326

327327
// define deployment option
328328
self.noDeploy = nodeployArgument
329-
330-
// define control on list endpoints after a deployment
329+
330+
// define control on list endpoints after a deployment
331331
self.noList = noListArgument
332332

333333
// define logging verbosity
@@ -362,7 +362,7 @@ private struct Configuration: CustomStringConvertible {
362362
if let stackName = stackNameArgument.first {
363363
self.stackName = stackName
364364
} else {
365-
self.stackName = context.package.displayName
365+
self.stackName = context.package.displayName
366366
}
367367

368368
if self.verboseLogging {

Plugins/AWSLambdaPackager/Plugin.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ struct AWSLambdaPackager: CommandPlugin {
112112
let buildCommand = "swift build -c \(buildConfiguration.rawValue) --product \(product.name) --static-swift-stdlib"
113113
try Utils.execute(
114114
executable: dockerToolPath,
115-
// arguments: ["run", "--rm", "-v", "\(packageDirectory.string):/workspace", "-w", "/workspace", baseImage, "bash", "-cl", buildCommand],
116-
arguments: ["run", "--rm", "-v", "\(packageDirectory.string)/../..:/workspace", "-w", "/workspace/Examples/SAM", baseImage, "bash", "-cl", buildCommand], logLevel: verboseLogging ? .debug : .output
115+
arguments: ["run", "--rm", "-v", "\(packageDirectory.string):/workspace", "-w", "/workspace", baseImage, "bash", "-cl", buildCommand],
117116
)
118117
let productPath = buildOutputPath.appending(product.name)
119118
guard FileManager.default.fileExists(atPath: productPath.string) else {

0 commit comments

Comments
 (0)