-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4b2ada
commit 14f1a82
Showing
4 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// LoggingTests.swift | ||
// MullvadVPNTests | ||
// | ||
// Created by Emils on 04/04/2024. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import XCTest | ||
@testable import MullvadLogging | ||
|
||
class MullvadLoggingTests: XCTestCase { | ||
func testLogHeader() { | ||
let dummySig = "test-sgi"; | ||
let testFileName = "test" | ||
let expectedHeader = "Header of a log file" | ||
|
||
var builder = LoggerBuilder() | ||
try! builder.addFileOutput(securityGroupIdentifier: dummySig, basename: testFileName) | ||
|
||
builder.install(header: expectedHeader) | ||
|
||
let logFileUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: dummySig)!.appendingPathComponent("Logs", isDirectory: true).appendingPathComponent("\(testFileName).log", isDirectory: false) | ||
|
||
let contents = String(decoding: try! Data(contentsOf: logFileUrl), as: UTF8.self) | ||
|
||
XCTAssert(contents.hasPrefix(expectedHeader)) | ||
XCTAssertEqual("\(expectedHeader)\n", contents) | ||
} | ||
} |