2023-03-20 23:58:40 +00:00
|
|
|
//
|
|
|
|
// PrinterRequestsManagerTests.swift
|
|
|
|
// SoyuzTests
|
|
|
|
//
|
|
|
|
// Created by maddiefuzz on 2/21/23.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
2023-04-05 17:49:05 +00:00
|
|
|
import Starscream
|
2023-03-20 23:58:40 +00:00
|
|
|
import Network
|
|
|
|
@testable import Soyuz
|
|
|
|
|
|
|
|
class PrinterRequestManagerTests: XCTestCase {
|
2023-04-05 17:49:05 +00:00
|
|
|
var socketManager: MoonrakerSocketManager?
|
2023-03-20 23:58:40 +00:00
|
|
|
|
2023-04-05 17:49:05 +00:00
|
|
|
// Server-side test variables
|
|
|
|
let server = WebSocketServer()
|
|
|
|
let address = "localhost"
|
|
|
|
let port: UInt16 = 80
|
|
|
|
|
|
|
|
override func setUp() {
|
|
|
|
let server = WebSocketServer()
|
|
|
|
|
|
|
|
let error = server.start(address: address, port: port)
|
|
|
|
|
|
|
|
if let err = error {
|
|
|
|
print("Error starting WebSocket server: \(err)")
|
|
|
|
}
|
|
|
|
|
|
|
|
socketManager = MoonrakerSocketManager()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testBlah() {
|
|
|
|
guard let url = URL(string: "\(address):\(port)") else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
print("Success")
|
|
|
|
let endpoint = NWEndpoint.url(url)
|
|
|
|
print(endpoint.debugDescription)
|
|
|
|
socketManager?.connectToBonjourEndpoint(endpoint)
|
|
|
|
return
|
|
|
|
}
|
2023-03-20 23:58:40 +00:00
|
|
|
|
2023-03-24 18:42:17 +00:00
|
|
|
// override func setUp() {
|
|
|
|
// printerRequestManager = PrinterRequestManager(browser: NWBrowser(for: .bonjour(type: "_http._tcp", domain: "local."), using: .tcp))
|
|
|
|
//
|
|
|
|
// // Set up test bonjour server
|
|
|
|
// //let parameters = NWParameters(tls: .none, tcp: NWListener.)
|
|
|
|
// do {
|
|
|
|
// testBonjourListener = try NWListener(using: .tcp, on: .http)
|
|
|
|
// testBonjourListener!.start(queue: DispatchQueue.main)
|
|
|
|
// } catch {
|
|
|
|
// print("Error: \(error)")
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func testBonjourDiscoveredItemsNotNil() {
|
|
|
|
// XCTAssertNotNil(printerRequestManager?.nwBrowserDiscoveredItems)
|
|
|
|
// }
|
2023-03-20 23:58:40 +00:00
|
|
|
}
|