Skip to content

Commit

Permalink
SPT-1998 fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Frolov authored and mrandrewsmith committed Mar 26, 2024
1 parent 7004bc5 commit 6a5629e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 49 deletions.
8 changes: 4 additions & 4 deletions NodeKit/Utils/Logging/LoggingContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import Foundation
protocol LoggingContextProtocol: Actor {
// Лог контекста
var log: Logable? { get }

/// Добавляет лог-сообщение к контексту.
/// - Parameter log: лог-сообщение.
func add(_ log: Logable?)
}

actor LoggingContext: LoggingContextProtocol {

// Лог контекста
public private(set) var log: Logable?

/// Добавляет лог-сообщение к контексту.
/// В случае, если у контекста не было лога, то он появится.
/// В случае, если у контекста был лог, но у него не было следующего, то этот добавится в качестве следующего лога.
Expand All @@ -45,5 +45,5 @@ actor LoggingContext: LoggingContextProtocol {
self.log = selfLog
return
}

}
4 changes: 2 additions & 2 deletions NodeKitTests/Utils/Equatable/Log+Equatalbe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
@testable import NodeKit

extension Log: Equatable {

public static func == (lhs: NodeKit.Log, rhs: NodeKit.Log) -> Bool {
return lhs.message == rhs.message &&
lhs.description == rhs.description &&
lhs.delimeter == rhs.delimeter &&
lhs.id == rhs.id &&
lhs.order == rhs.order
}

}
86 changes: 43 additions & 43 deletions NodeKitTests/Utils/LoggingContextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,103 +10,103 @@
import XCTest

final class LoggingContextTests: XCTestCase {

// MARK: - Sut

private var sut: LoggingContext!

// MARK: - Lifecycle

override func setUp() {
super.setUp()
sut = LoggingContext()
}

override func tearDown() {
super.tearDown()
sut = nil
}

// MARK: - Tests

func testLog_whenNothingAppending_thenResultIsNil() async {
// when

let result = await sut.log

// then

XCTAssertNil(result)
}

func testLog_whenOneItemAppending_therResultIsAppendedItem() async throws {
// given

let testLog = Log("Test message", id: "Test id")

// when

await sut.add(testLog)

let log = await sut.log
let result = try XCTUnwrap(log as? Log)

// then

XCTAssertEqual(result, testLog)
}

func testLog_whenTwoItemsAppending_thenResultIsFirstItemAndNextIsSecondItem() async throws {
// given

let firstLog = Log("Test first message", id: "Test first id")
let secondLog = Log("Test second message", id: "Test second id")

var expectedLog = firstLog
expectedLog.next = secondLog

// when

await sut.add(firstLog)
await sut.add(secondLog)

let log = await sut.log
let result = try XCTUnwrap(log as? Log)
let resultNext = try XCTUnwrap(result.next as? Log)

// then

XCTAssertEqual(result, expectedLog)
XCTAssertEqual(resultNext, secondLog)
XCTAssertNil(resultNext.next)
}

func testLog_whenThreeItemsAppending_thenResultIsFirstItemAndNextIsTree() async throws {
// given

let firstLog = Log("Test first message", id: "Test first id")
let secondLog = Log("Test second message", id: "Test second id")
let thirdLog = Log("Test third message", id: "Test third id")

var expectedLog = firstLog
var expectedThirdLog = thirdLog

expectedThirdLog.next = secondLog
expectedLog.next = expectedThirdLog

// when

await sut.add(firstLog)
await sut.add(secondLog)
await sut.add(thirdLog)

let log = await sut.log
let result = try XCTUnwrap((log) as? Log)
let firstNextResult = try XCTUnwrap(result.next as? Log)
let secondNextResult = try XCTUnwrap(firstNextResult.next as? Log)

// then

XCTAssertEqual(result, expectedLog)
XCTAssertEqual(firstNextResult, expectedThirdLog)
XCTAssertEqual(secondNextResult, secondLog)
Expand All @@ -115,40 +115,40 @@ final class LoggingContextTests: XCTestCase {

func testLog_whenFourItemsAppending_thenResultIsFirstItemAndNextIsTree() async throws {
// given

let firstLog = Log("Test first message", id: "Test first id")
let secondLog = Log("Test second message", id: "Test second id")
let thirdLog = Log("Test third message", id: "Test third id")
let fourthLog = Log("Test fourth message", id: "Test fourth id")

var expectedLog = firstLog
var expectedFourthLog = fourthLog
var expectedThirdLog = thirdLog

expectedThirdLog.next = secondLog
expectedFourthLog.next = expectedThirdLog
expectedLog.next = expectedFourthLog

// when

await sut.add(firstLog)
await sut.add(secondLog)
await sut.add(thirdLog)
await sut.add(fourthLog)

let log = await sut.log
let result = try XCTUnwrap(log as? Log)
let firstNextResult = try XCTUnwrap(result.next as? Log)
let secondNextResult = try XCTUnwrap(firstNextResult.next as? Log)
let thirdNextResult = try XCTUnwrap(secondNextResult.next as? Log)

// then

XCTAssertEqual(result, expectedLog)
XCTAssertEqual(firstNextResult, expectedFourthLog)
XCTAssertEqual(secondNextResult, expectedThirdLog)
XCTAssertEqual(thirdNextResult, secondLog)
XCTAssertNil(thirdNextResult.next)
}

}

0 comments on commit 6a5629e

Please sign in to comment.