aboutsummaryrefslogtreecommitdiff
path: root/Tests/swiftGopherClientTests/swiftGopherClientTests.swift
blob: 707ff3281ea53d745cadf2a0e72d1cbac9a6bc2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
//  swiftGopherClientTests.swift
//
//
//  Created by Navan Chauhan on 12/12/23.
//

import NIO
import XCTest

@testable import swiftGopherClient

final class GopherClientTests: XCTestCase {

    override func setUp() {
        super.setUp()
    }

    override func tearDown() {
        super.tearDown()
    }

    func testGopherServerConnection() {
        let expectation = XCTestExpectation(
            description: "Connect and receive response from Gopher server")
        let client = GopherClient()
        client.sendRequest(to: "gopher.floodgap.com", message: "\r\n") { result in
            switch result {
            case .success(_):
                expectation.fulfill()
            case .failure(let error):
                print("Error \(error)")
            }
        }

        wait(for: [expectation], timeout: 30)
    }

    func testGopherClientAsync() async throws {
        let client = GopherClient()
        let reply = try await client.sendRequest(to: "gopher.navan.dev", message: "\r\n")
        XCTAssertNotNil(reply)
    }
}