Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafiki270 committed Mar 26, 2018
1 parent efb7e86 commit 723ab62
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/AppVaporTestTools/routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public func routes(_ router: Router) throws {

router.get("ping") { (req)->Future<MyObject> in
let ping = "{ \"code\": \"pong\" }"
return try JSONDecoder().decode(MyObject.self, from: HTTPBody(string: ping))
return try JSONDecoder().decode(MyObject.self, from: HTTPBody(string: ping), maxSize: 500, on: req)
}

// Example of creating a Service and using it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension TestableProperty where TestableType: Response {
print("\t\(header.name.description) = \(header.value)")
}
print("Content:")
if let size = element.content.body?.count {
if let size = element.content.body.count {
print("\tSize: \(String(size))")
}
if let mediaType = element.content.mediaType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ extension TestableProperty where TestableType: Response {
}

public var contentSize: Int? {
return element.content.body?.count
return element.content.body.count
}

public var contentString: String? {

guard let data = try? element.content.body?.consumeData(max: 500000, on: fakeRequest()).wait() else {
guard let data = try? element.content.body.consumeData(max: 500000, on: fakeRequest()).wait() else {
return nil
}
return String(data: data!, encoding: .utf8)
return String(data: data, encoding: .utf8)
}

public func contentString(encoding: String.Encoding) -> String? {
guard let data = try? element.content.body?.consumeData(max: 500000, on: fakeRequest()).wait() else {
guard let data = try? element.content.body.consumeData(max: 500000, on: fakeRequest()).wait() else {
return nil
}
return String(data: data!, encoding: encoding)
return String(data: data, encoding: encoding)
}

}
6 changes: 6 additions & 0 deletions scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

rm -rf .build
vapor clean --verbose -y
rm Package.resolved
vapor xcode --verbose -y

0 comments on commit 723ab62

Please sign in to comment.