CommandLineToolkit

Форк
0
/
NSLogLikeLogEntryTextFormatterTests.swift 
64 строки · 1.8 Кб
1
/*
2
 * Copyright (c) Avito Tech LLC
3
 */
4

5
import Foundation
6
import CLTLogging
7
import CLTLoggingModels
8
import XCTest
9

10
final class NSLogLikeLogEntryTextFormatterTests: XCTestCase {
11
    func test___with_location_with_coordinates() {
12
        let formatter = NSLogLikeLogEntryTextFormatter(
13
            logLocation: true,
14
            logCoordinates: true
15
        )
16
        
17
        let entry = LogEntry(
18
            file: "file",
19
            line: 42,
20
            coordinates: [
21
                LogEntryCoordinate(name: "some"),
22
                LogEntryCoordinate(name: "coordinate", value: "value"),
23
            ],
24
            message: "message",
25
            timestamp: Date(),
26
            verbosity: .always
27
        )
28
        let text = formatter.format(logEntry: entry)
29
        
30
        let expectedTimestamp = NSLogLikeLogEntryTextFormatter.logDateFormatter.string(from: entry.timestamp)
31
        
32
        XCTAssertEqual(
33
            text,
34
            "[ALWAYS] \(expectedTimestamp) file:42 some coordinate:value: message"
35
        )
36
    }
37
    
38
    func test___without_location_without_coordinates() {
39
        let formatter = NSLogLikeLogEntryTextFormatter(
40
            logLocation: false,
41
            logCoordinates: false
42
        )
43
        
44
        let entry = LogEntry(
45
            file: "file",
46
            line: 42,
47
            coordinates: [
48
                LogEntryCoordinate(name: "some"),
49
                LogEntryCoordinate(name: "coordinate", value: "value"),
50
            ],
51
            message: "message",
52
            timestamp: Date(),
53
            verbosity: .always
54
        )
55
        let text = formatter.format(logEntry: entry)
56
        
57
        let expectedTimestamp = NSLogLikeLogEntryTextFormatter.logDateFormatter.string(from: entry.timestamp)
58
        
59
        XCTAssertEqual(
60
            text,
61
            "[ALWAYS] \(expectedTimestamp): message"
62
        )
63
    }
64
}
65

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.