Skip to content

Commit

Permalink
Merge pull request #90 from swift-aws/fix-build-error
Browse files Browse the repository at this point in the history
Fix build error with Swift 4.2.1
  • Loading branch information
jonnymacs committed Dec 4, 2018
2 parents 5383778 + e732ae3 commit d5727e9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ let package = Package(
.target(name: "ResourceGroupsTaggingAPI", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/ResourceGroupsTaggingAPI"),
.target(name: "Route53", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/Route53"),
.target(name: "Route53Domains", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/Route53Domains"),
.target(name: "S3", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/S3"),
.target(name: "S3", dependencies: ["AWSSDKSwiftCore", "S3Middleware"], path: "./Sources/AWSSDKSwift/Services/S3"),
.target(name: "SES", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/SES"),
.target(name: "SFN", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/SFN"),
.target(name: "SMS", dependencies: ["AWSSDKSwiftCore"], path: "./Sources/AWSSDKSwift/Services/SMS"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSSDKSwift/Services/S3/S3_API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,4 @@ public struct S3 {
}


}
}
38 changes: 19 additions & 19 deletions Tests/AWSSDKSwiftTests/Services/Dynamodb/DynamoDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import Dispatch
import XCTest
@testable import Dynamodb
@testable import DynamoDB

class DynamoDBTests: XCTestCase {
static var allTests : [(String, (DynamoDBTests) -> () throws -> Void)] {
Expand All @@ -18,8 +18,8 @@ class DynamoDBTests: XCTestCase {
]
}

var client: Dynamodb {
return Dynamodb(
var client: DynamoDB {
return DynamoDB(
accessKeyId: "key",
secretAccessKey: "secret",
region: .apnortheast1,
Expand All @@ -32,24 +32,24 @@ class DynamoDBTests: XCTestCase {
}

func prepare() throws {
let createTableInput = Dynamodb.CreateTableInput(
attributeDefinitions: [
Dynamodb.AttributeDefinition(attributeType: .s, attributeName: "hashKey"),
Dynamodb.AttributeDefinition(attributeType: .s, attributeName: "rangeKey")
],
let createTableInput = DynamoDB.CreateTableInput(
keySchema: [
Dynamodb.KeySchemaElement(attributeName: "hashKey", keyType: .hash),
Dynamodb.KeySchemaElement(attributeName: "rangeKey", keyType: .range)
DynamoDB.KeySchemaElement(attributeName: "hashKey", keyType: .hash),
DynamoDB.KeySchemaElement(attributeName: "rangeKey", keyType: .range)
],
provisionedThroughput: Dynamodb.ProvisionedThroughput(writeCapacityUnits: 10, readCapacityUnits: 10),
tableName: tableName
tableName: tableName,
attributeDefinitions: [
DynamoDB.AttributeDefinition(attributeName: "hashKey", attributeType: .s),
DynamoDB.AttributeDefinition(attributeName: "rangeKey", attributeType: .s)
],
provisionedThroughput: DynamoDB.ProvisionedThroughput(readCapacityUnits: 10, writeCapacityUnits: 10)
)
_ = try client.createTable(createTableInput)

let putItemInput = Dynamodb.PutItemInput(
let putItemInput = DynamoDB.PutItemInput(
item: [
"hashKey": Dynamodb.AttributeValue(s: "hello"),
"rangeKey": Dynamodb.AttributeValue(s: "world")
"hashKey": DynamoDB.AttributeValue(s: "hello"),
"rangeKey": DynamoDB.AttributeValue(s: "world")
],
tableName: tableName
)
Expand All @@ -58,7 +58,7 @@ class DynamoDBTests: XCTestCase {

override func tearDown() {
do {
let input = Dynamodb.DeleteTableInput(tableName: tableName)
let input = DynamoDB.DeleteTableInput(tableName: tableName)
_ = try client.deleteTable(input)
} catch {
print(error)
Expand All @@ -68,10 +68,10 @@ class DynamoDBTests: XCTestCase {
func testGetObject() {
do {
try prepare()
let input = Dynamodb.GetItemInput(
let input = DynamoDB.GetItemInput(
key: [
"hashKey": Dynamodb.AttributeValue(s: "hello"),
"rangeKey": Dynamodb.AttributeValue(s: "world")
"hashKey": DynamoDB.AttributeValue(s: "hello"),
"rangeKey": DynamoDB.AttributeValue(s: "world")
],
tableName: tableName
)
Expand Down
23 changes: 13 additions & 10 deletions Tests/AWSSDKSwiftTests/Services/S3/S3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ class S3Tests: XCTestCase {

func testPutObject() throws {
let putRequest = S3.PutObjectRequest(
bucket: TestData.shared.bucket,
body: TestData.shared.bodyData,
contentLength: Int64(TestData.shared.bodyData.count),
key: TestData.shared.key,
body: TestData.shared.bodyData,
acl: .publicRead)
acl: .publicRead,
bucket: TestData.shared.bucket
)

let output = try client.putObject(putRequest)
XCTAssertNotNil(output.eTag)
Expand All @@ -55,24 +56,26 @@ class S3Tests: XCTestCase {

func testGetObject() throws {
let putRequest = S3.PutObjectRequest(
bucket: TestData.shared.bucket,
body: TestData.shared.bodyData,
contentLength: Int64(TestData.shared.bodyData.count),
key: TestData.shared.key,
body: TestData.shared.bodyData,
acl: .publicRead)
acl: .publicRead,
bucket: TestData.shared.bucket
)

_ = try client.putObject(putRequest)
let object = try client.getObject(S3.GetObjectRequest(bucket: TestData.shared.bucket, key: "hello.txt"))
let object = try client.getObject(S3.GetObjectRequest(key: "hello.txt", bucket: TestData.shared.bucket))
XCTAssertEqual(object.body, TestData.shared.bodyData)
}

func testListObjects() throws {
let putRequest = S3.PutObjectRequest(
bucket: TestData.shared.bucket,
body: TestData.shared.bodyData,
contentLength: Int64(TestData.shared.bodyData.count),
key: TestData.shared.key,
body: TestData.shared.bodyData,
acl: .publicRead)
acl: .publicRead,
bucket: TestData.shared.bucket
)

let putResult = try client.putObject(putRequest)

Expand Down
8 changes: 7 additions & 1 deletion scripts/generate_targets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ print(libraries)


//TODO(Yasumoto): Need to auto-add S3RequestMiddleware to S3 module dependency
let servicesTargetDefinitions = services.map { " .target(name: \"\($0)\", dependencies: [\"AWSSDKSwiftCore\"], path: \"\(servicesBasePath)/\($0)\")," }
let servicesTargetDefinitions = services.map { (serviceName) -> String in
if let middleware = middlewares.first(where: { $0 == serviceName }) {
return " .target(name: \"\(serviceName)\", dependencies: [\"AWSSDKSwiftCore\", \"\(middleware)Middleware\"], path: \"\(servicesBasePath)/\(serviceName)\"),"
} else {
return " .target(name: \"\(serviceName)\", dependencies: [\"AWSSDKSwiftCore\"], path: \"\(servicesBasePath)/\(serviceName)\"),"
}
}
_ = servicesTargetDefinitions.sorted().map { print($0) }

let middlewaresTargetDefinitions = middlewares.map { " .target(name: \"\($0)Middleware\", dependencies: [\"AWSSDKSwiftCore\"], path: \"\(middlewaresBasePath)/\($0)\")," }
Expand Down

0 comments on commit d5727e9

Please sign in to comment.