-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtil.swift
59 lines (42 loc) · 1.6 KB
/
Util.swift
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@testable import Coder_Desktop
import Combine
import NetworkExtension
import SwiftUI
import ViewInspector
import VPNLib
@MainActor
class MockVPNService: VPNService, ObservableObject {
@Published var state: Coder_Desktop.VPNServiceState = .disabled
@Published var baseAccessURL: URL = .init(string: "https://dev.coder.com")!
@Published var menuState: VPNMenuState = .init()
var onStart: (() async -> Void)?
var onStop: (() async -> Void)?
func start() async {
state = .connecting
await onStart?()
}
func stop() async {
state = .disconnecting
await onStop?()
}
func configureTunnelProviderProtocol(proto _: NETunnelProviderProtocol?) {}
var startWhenReady: Bool = false
}
@MainActor
class MockFileSyncDaemon: FileSyncDaemon {
var logFile: URL = .init(filePath: "~/log.txt")
var sessionState: [VPNLib.FileSyncSession] = []
func refreshSessions() async {}
func deleteSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
var state: VPNLib.DaemonState = .running
func tryStart() async {}
func stop() async {}
func listSessions() async throws -> [VPNLib.FileSyncSession] {
[]
}
func createSession(localPath _: String, agentHost _: String, remotePath _: String) async throws(DaemonError) {}
func pauseSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
func resumeSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
func resetSessions(ids _: [String]) async throws(VPNLib.DaemonError) {}
}
extension Inspection: @unchecked Sendable, @retroactive InspectionEmissary {}