34 lines
902 B
Swift
34 lines
902 B
Swift
|
@testable import App
|
||
|
import XCTVapor
|
||
|
|
||
|
final class AppTests: XCTestCase {
|
||
|
func testHelloWorld() async throws {
|
||
|
let app = Application(.testing)
|
||
|
defer { app.shutdown() }
|
||
|
try await configure(app)
|
||
|
|
||
|
try app.test(.GET, "hello", afterResponse: { res in
|
||
|
XCTAssertEqual(res.status, .ok)
|
||
|
XCTAssertEqual(res.body.string, "Hello, world!")
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func testDecodeConfigurationWithoutOptionalValues() throws {
|
||
|
let domainConfig = DomainConfiguration(domains: ["some.more"], password: "secret", useIPv4: true, useIPv6: false)
|
||
|
|
||
|
let content =
|
||
|
"""
|
||
|
{
|
||
|
"domains": [
|
||
|
"some.more"
|
||
|
],
|
||
|
"useIPv6": false,
|
||
|
"password":"secret"
|
||
|
}
|
||
|
"""
|
||
|
let data = content.data(using: .utf8)!
|
||
|
let decoded = try JSONDecoder().decode(DomainConfiguration.self, from: data)
|
||
|
XCTAssertEqual(domainConfig, decoded)
|
||
|
}
|
||
|
}
|