First version
This commit is contained in:
33
Tests/AppTests/AppTests.swift
Normal file
33
Tests/AppTests/AppTests.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
@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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user