-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from qutheory/vapor-12
vapor 12
- Loading branch information
Showing
11 changed files
with
74 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
Sources/main.swift | ||
Packages | ||
.build | ||
Resources | ||
*.xcodeproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{>a}} | ||
|
||
Hello, {{name}} | ||
|
||
{{>b}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#if os(Linux) | ||
|
||
import XCTest | ||
@testable import VaporMustacheTestSuite | ||
|
||
XCTMain([ | ||
testCase(ProviderTests.allTests), | ||
]) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import XCTest | ||
@testable import VaporMustache | ||
import Vapor | ||
|
||
class ProviderTests: XCTestCase { | ||
static let allTests = [ | ||
("testSaveAndFind", testSaveAndFind) | ||
] | ||
|
||
func testSaveAndFind() { | ||
let provider = Provider(withIncludes: [ | ||
"a": "Includes/test-include-a.mustache", | ||
"b": "Includes/test-include-b.mustache", | ||
]) | ||
|
||
let app = Application(providers: [provider]) | ||
|
||
let name = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^*()" | ||
|
||
do { | ||
let view = try app.view("test-view.mustache", context: ["name": name]) | ||
|
||
let response = view.makeResponse() | ||
|
||
switch response.body { | ||
case .data(let bytes): | ||
let encoded = String(name.characters.split(separator: "&").joined(separator: "&".characters)) | ||
let expected = "a\n\nHello, \(encoded)\n\nb" | ||
|
||
let string = try bytes.toString() | ||
XCTAssertEqual(string, expected, "Template did not render properly") | ||
case .chunked(_): | ||
XCTFail("Incorrect body type") | ||
} | ||
} catch { | ||
XCTFail("Could not make view: \(error)") | ||
} | ||
} | ||
} |
Empty file.