Skip to content

Commit

Permalink
Rename mock properties
Browse files Browse the repository at this point in the history
  • Loading branch information
EgzonArifi committed Jan 13, 2025
1 parent f328b3d commit a26e9d2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private extension ConfigInitialFileGeneratorTests {

func makeSUT(shouldFail: String? = .none, encoder: JSONEncoding? = nil) -> (sut: ConfigInitialFileGenerator, actors: Actors) {
let contentFilesCreator = MockContentFilesCreator()
contentFilesCreator.shouldThrowError = shouldFail
contentFilesCreator.errorMessage = shouldFail
let config = Config.createTemplateConfig()
let transformer = ConfigTransformer()
let fileName = "config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest

final class LocalizedPlatformFilesGeneratorTests: XCTestCase {
func test_createPlatformFiles_createsFilesSuccessfully() throws {
let (contentGenerator, filesCreator) = makeContentGeneratorAndCreator(shouldFilesCreatorThrowError: .none)
let (contentGenerator, filesCreator) = makeContentGeneratorAndCreator(filesCreatorThrownErrorMessage: .none)
let fileExtension = "txt"
let fileNameGenerator = MockPlatformFilesNameGenerator(fileExtension: fileExtension)
let sut = makeSUT(contentGenerator: contentGenerator, filesCreator: filesCreator, fileNameGenerator: fileNameGenerator)
Expand All @@ -18,7 +18,7 @@ final class LocalizedPlatformFilesGeneratorTests: XCTestCase {
}

func test_createPlatformFiles_throwsErrorAndLogsMessage_onCreateFilesFailure() {
let (contentGenerator, filesCreator) = makeContentGeneratorAndCreator(shouldFilesCreatorThrowError: "Error_message")
let (contentGenerator, filesCreator) = makeContentGeneratorAndCreator(filesCreatorThrownErrorMessage: "Error_message")
let sut = makeSUT(contentGenerator: contentGenerator, filesCreator: filesCreator)
let entries: [LocalizationEntry] = [.create(plural: true)]
let outputFolder = URL(fileURLWithPath: NSTemporaryDirectory())
Expand All @@ -32,12 +32,12 @@ final class LocalizedPlatformFilesGeneratorTests: XCTestCase {
}

func makeContentGeneratorAndCreator(
shouldFilesCreatorThrowError: String?
filesCreatorThrownErrorMessage: String?
) -> (contentGenerator: MockLocalizedContentGenerator, filesCreator: MockContentFilesCreator) {
let contentGenerator = MockLocalizedContentGenerator()
contentGenerator.content = ("stringsContent", "stringsDictContent")
let filesCreator = MockContentFilesCreator()
filesCreator.shouldThrowError = shouldFilesCreatorThrowError
filesCreator.errorMessage = filesCreatorThrownErrorMessage
return (contentGenerator, filesCreator)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import Foundation

class MockContentFilesCreator: ContentFileCreatable {
var writtenContent: [String: String] = [:]
var shouldThrowError: String?
var errorMessage: String?

func createFiles(with content: String, fileName: String, outputFolder: URL) throws {
try createFilesInCurrentDirectory(with: content, fileName: fileName)
}

func createFilesInCurrentDirectory(with content: String, fileName: String) throws {
if let shouldThrowError {
throw DirectoryOperationError.folderCreationFailed(shouldThrowError)
if let errorMessage {
throw DirectoryOperationError.folderCreationFailed(errorMessage)
}
writtenContent[fileName] = content
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class SwiftLocalizedCodeFileGeneratorTests: XCTestCase {
func test_generate_printsErrorOnCreateFilesFailure() {
let mockLogger = MockLogger()
let mockContentFilesCreator = MockContentFilesCreator()
mockContentFilesCreator.shouldThrowError = "Error_message"
mockContentFilesCreator.errorMessage = "Error_message"
let sut = makeSUT(mockLogger: mockLogger,
mockContentFilesCreator: mockContentFilesCreator)

Expand Down

0 comments on commit a26e9d2

Please sign in to comment.