Skip to content

Commit

Permalink
Remove repository tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-vysotskyi-cko committed Jul 7, 2023
1 parent 61220ff commit e3a1ccb
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 130 deletions.
29 changes: 29 additions & 0 deletions Tests/ProcessOutTests/Sources/Core/Utils.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Utils.swift
// ProcessOut
//
// Created by Andrii Vysotskyi on 07.07.2023.
//

import XCTest

/// Asserts that an expression throws an error.
/// - Parameters:
/// - expression: An expression that can throw an error.
/// - message: An optional description of a failure.
/// - errorHandler: An optional handler for errors that expression throws.
func assertThrowsError<T>(
_ expression: @autoclosure () async throws -> T,
_ message: @autoclosure () -> String = "",
file: StaticString = #filePath,
line: UInt = #line,
_ errorHandler: (_ error: Error) -> Void = { _ in }
) async {
do {
_ = try await expression()
} catch {
errorHandler(error)
return
}
XCTFail(message(), file: file, line: line)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import XCTest
@_spi(PO) import ProcessOut

final class CardsServiceTests: XCTestCase {
@MainActor final class CardsServiceTests: XCTestCase {

override func setUp() {
super.setUp()
Expand Down Expand Up @@ -52,6 +52,32 @@ final class CardsServiceTests: XCTestCase {
XCTAssertEqual(card.expYear, 2040)
}

func test_issuerInformation_whenIinIsTooShort_throws() async {
// Given
let iin = "4"

// When
let issuerInformation = {
try await self.sut.issuerInformation(iin: iin)
}

// Then
await assertThrowsError(try await issuerInformation(), "IIN with length less than 6 symbols should be invalid")
}

func test_tokenizeRequest_whenNumberIsInvalid_throwsError() async {
// Given
let request = POCardTokenizationRequest(number: "", expMonth: 12, expYear: 40, cvc: "737")

// When
let card = {
try await self.sut.tokenize(request: request)
}

// Then
await assertThrowsError(try await card(), "Unexpected success, card number is invalid")
}

func test_updateCard() async throws {
// Given
let cardTokenizationRequest = POCardTokenizationRequest(
Expand Down

This file was deleted.

0 comments on commit e3a1ccb

Please sign in to comment.