Skip to content

Commit

Permalink
Merge pull request #46 from eugeneego/async-cleanup
Browse files Browse the repository at this point in the history
Async cleanup
  • Loading branch information
eugeneego authored Jul 14, 2024
2 parents 68956f7 + e0a2e42 commit 6130892
Show file tree
Hide file tree
Showing 67 changed files with 551 additions and 401 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift

name: Build and tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: macos-latest

steps:
- uses: actions/checkout@v4
- name: Build
run: swift build
- name: Run tests
run: swift test
7 changes: 4 additions & 3 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ disabled_rules:
- type_body_length

opt_in_rules:
- anyobject_protocol
- array_init
- closure_end_indentation
- closure_spacing
Expand Down Expand Up @@ -52,12 +51,14 @@ opt_in_rules:
- trailing_closure
- multiple_closures_with_trailing_closure
- unneeded_parentheses_in_closure_argument
- unused_import
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- yoda_condition

analyzer_rules:
- unused_import

excluded:
- Carthage
- Pods
Expand All @@ -82,7 +83,7 @@ vertical_whitespace:
severity: warning

switch_case_alignment:
indented_cases: true
indented_cases: false

comma: error
colon:
Expand Down
11 changes: 11 additions & 0 deletions Legacy-iOSTests/DeviceInfoTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ import XCTest
@testable import Legacy

class DeviceInfoTests: XCTestCase {
@MainActor
func testMain() {
let deviceInfo = DeviceInfo.main

XCTAssert(!deviceInfo.machineName.isEmpty)
XCTAssert(!deviceInfo.machineDisplayName.isEmpty)
XCTAssert(!deviceInfo.system.isEmpty)
XCTAssert(!deviceInfo.systemVersion.isEmpty)

XCTAssert(!deviceInfo.bundleName.isEmpty)
XCTAssert(!deviceInfo.bundleDisplayName.isEmpty)
XCTAssert(!deviceInfo.bundleIdentifier.isEmpty)
XCTAssert(!deviceInfo.bundleVersion.isEmpty)
XCTAssert(!deviceInfo.bundleBuild.isEmpty)
}

#if os(iOS)
@MainActor
func testBundle() {
let deviceInfo = DeviceInfo(bundle: Bundle(for: DeviceInfoTests.self))

Expand All @@ -36,6 +45,7 @@ class DeviceInfoTests: XCTestCase {
XCTAssert(!deviceInfo.bundleBuild.isEmpty)
}

@MainActor
func testClass() {
let deviceInfo = DeviceInfo(class: Odin.self)

Expand All @@ -50,6 +60,7 @@ class DeviceInfoTests: XCTestCase {
XCTAssert(!deviceInfo.bundleVersion.isEmpty)
XCTAssert(!deviceInfo.bundleBuild.isEmpty)
}
#endif
}

#endif
25 changes: 13 additions & 12 deletions Legacy-iOSTests/EETestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension XCTestCase {
typealias ExpectationHandler = (_ desctiption: String, _ expectation: XCTestExpectation) -> Void

/// Asynchronous expectation helper.
@MainActor
func expect(
_ description: String,
timeout: TimeInterval = 15,
Expand Down Expand Up @@ -82,12 +83,12 @@ func EEAssertSuccess<T, E>(
line: UInt = #line
) -> T? {
switch result {
case .success(let value):
return value
case .failure(let error):
XCTFail("\(description): success expected, but got: \(errorDebugDescription(error))", file: file, line: line)
expectation?.fulfill()
return nil
case .success(let value):
return value
case .failure(let error):
XCTFail("\(description): success expected, but got: \(errorDebugDescription(error))", file: file, line: line)
expectation?.fulfill()
return nil
}
}

Expand Down Expand Up @@ -117,12 +118,12 @@ func EEAssertFailure<T, E>(
line: UInt = #line
) -> E? {
switch result {
case .success:
XCTFail("\(description): failure expected", file: file, line: line)
expectation?.fulfill()
return nil
case .failure(let error):
return error
case .success:
XCTFail("\(description): failure expected", file: file, line: line)
expectation?.fulfill()
return nil
case .failure(let error):
return error
}
}

Expand Down
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/PartialPostLightTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -46,3 +45,4 @@ struct PartialPostLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/PartialPostTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -84,3 +83,4 @@ struct PartialPostTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/PostLightTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -46,3 +45,4 @@ struct PostLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/PostTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -84,3 +83,4 @@ struct PostTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -36,3 +35,4 @@ struct UserAddressGeoPointLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -64,3 +63,4 @@ struct UserAddressGeoPointTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserAddressLightTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -51,3 +50,4 @@ struct UserAddressLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserAddressTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -94,3 +93,4 @@ struct UserAddressTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserCompanyLightTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -41,3 +40,4 @@ struct UserCompanyLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserCompanyTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -74,3 +73,4 @@ struct UserCompanyTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserLightTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -66,3 +65,4 @@ struct UserLightTransformer: LightTransformer {
return dictionary
}
}
// swiftlint:enable all
4 changes: 2 additions & 2 deletions Legacy-iOSTests/Generated/UserTransformer.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Generated using Sourcery 0.16.2 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

import Foundation
import CoreGraphics
import Legacy
Expand Down Expand Up @@ -124,3 +123,4 @@ struct UserTransformer: Transformer {
return .success(dictionary)
}
}
// swiftlint:enable all
3 changes: 1 addition & 2 deletions Legacy-iOSTests/Network/NetworkTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class NetworkTestCase: XCTestCase {
let configuration = URLSessionConfiguration.default
configuration.urlCache = nil
configuration.requestCachePolicy = .reloadIgnoringLocalAndRemoteCacheData
let logger = DefaultUrlSessionHttpLogger(logger: PrintLogger())
let http = UrlSessionHttp(configuration: configuration, logger: logger)
let http = UrlSessionHttp(configuration: configuration, logger: nil)
let rest = BaseRestClient(http: http, baseUrl: baseUrl)
return rest
}()
Expand Down
Loading

0 comments on commit 6130892

Please sign in to comment.