Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the beginning of unit tests fro StartTunnelOperation #5758

Merged
merged 9 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tidying
  • Loading branch information
acb-mv authored and buggmagnet committed Feb 7, 2024
commit 881574a30f1ed8b0d6b27fb9eab88f10860b5af8
17 changes: 5 additions & 12 deletions ios/MullvadVPNTests/Mocks/MockTunnelInteractor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import PacketTunnelCore
struct MockTunnelInteractor: TunnelInteractor {
var onUpdateTunnelStatus: ((TunnelStatus)->Void)?


var tunnel: (TunnelProtocol)?

func getPersistentTunnels() -> [TunnelProtocol] {
Expand All @@ -26,7 +25,6 @@ struct MockTunnelInteractor: TunnelInteractor {
}

func setTunnel(_ tunnel: (TunnelProtocol)?, shouldRefreshTunnelState: Bool) {

}

var tunnelStatus: TunnelStatus =
Expand All @@ -45,26 +43,21 @@ struct MockTunnelInteractor: TunnelInteractor {

var deviceState: MullvadSettings.DeviceState

func setConfigurationLoaded() {
}
func setConfigurationLoaded() {}

func setSettings(_ settings: MullvadSettings.LatestTunnelSettings, persist: Bool) {
}

func setDeviceState(_ deviceState: MullvadSettings.DeviceState, persist: Bool) {
}

func removeLastUsedAccount() {
}
func removeLastUsedAccount() {}

func handleRestError(_ error: Error) {
}
func handleRestError(_ error: Error) {}

func startTunnel() {
}
func startTunnel() {}

func prepareForVPNConfigurationDeletion() {
}
func prepareForVPNConfigurationDeletion() {}

func selectRelay() throws -> PacketTunnelCore.SelectedRelay {
fatalError()
Expand Down
12 changes: 3 additions & 9 deletions ios/MullvadVPNTests/StartTunnelOperationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ final class StartTunnelOperationTests: XCTestCase {

let testQueue = DispatchQueue(label: "StartTunnelOperationTests.testQueue")

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testFailsIfNotLoggedIn() throws {
let operationQueue = AsyncOperationQueue()
let settings = LatestTunnelSettings()
Expand All @@ -45,6 +37,7 @@ final class StartTunnelOperationTests: XCTestCase {
}

func testSetsReconnectIfDisconnecting() {
let operationQueue = AsyncOperationQueue()
let settings = LatestTunnelSettings()
var interactor = MockTunnelInteractor(
isConfigurationLoaded: true,
Expand Down Expand Up @@ -78,6 +71,7 @@ final class StartTunnelOperationTests: XCTestCase {
XCTAssertEqual(tunnelStatus.state, .disconnecting(.reconnect))
expectation.fulfill()
}
operationQueue.addOperation(operation)
wait(for: [expectation], timeout: 10.0)
}

}