-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from taji-taji/use-general-mock
Use general mock
- Loading branch information
Showing
6 changed files
with
193 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Tests/DangerSwiftPeripheryTests/Mocks/CheckstyleOutputParsableMock.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Created by 多鹿豊 on 2022/07/24. | ||
// | ||
|
||
import Foundation | ||
@testable import DangerSwiftPeriphery | ||
|
||
final class CheckstyleOutputParsableMock: CheckstyleOutputParsable { | ||
var parseHandler: ((String) throws -> [Violation])? | ||
var projectRootPath: String | ||
|
||
init(projectRootPath: String) { | ||
self.projectRootPath = projectRootPath | ||
} | ||
|
||
func parse(xml: String) throws -> [Violation] { | ||
guard let handler = parseHandler else { | ||
fatalError("parseHandler is nil.") | ||
} | ||
return try handler(xml) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Tests/DangerSwiftPeripheryTests/Mocks/PeripheryScanExecutableMock.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// Created by 多鹿豊 on 2022/07/24. | ||
// | ||
|
||
import Foundation | ||
@testable import DangerSwiftPeriphery | ||
|
||
final class PeripheryScanExecutableMock: PeripheryScanExecutable { | ||
var executeHandler: (() throws -> String)? | ||
|
||
func execute() throws -> String { | ||
guard let executeHandler = executeHandler else { | ||
fatalError("executeHandler is nil.") | ||
} | ||
return try executeHandler() | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Tests/DangerSwiftPeripheryTests/Mocks/PullRequestDiffProvidableMock.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by 多鹿豊 on 2022/07/24. | ||
// | ||
|
||
import Foundation | ||
import Danger | ||
@testable import DangerSwiftPeriphery | ||
|
||
final class PullRequestDiffProvidableMock: PullRequestDiffProvidable { | ||
var diffHandler: ((String) -> Result<FileDiff.Changes, Error>)? | ||
|
||
func diff(forFile: String) -> Result<FileDiff.Changes, Error> { | ||
guard let handler = diffHandler else { | ||
fatalError("diffHandler is nil.") | ||
} | ||
return handler(forFile) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Tests/DangerSwiftPeripheryTests/Mocks/ShellExecutableMock.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Created by 多鹿豊 on 2022/07/24. | ||
// | ||
|
||
import Foundation | ||
@testable import DangerSwiftPeriphery | ||
|
||
final class ShellExecutableMock: ShellExecutable { | ||
var executeHandler: ((String, [String]) -> Result<String, CommandError>)? | ||
|
||
func execute(_ command: String) -> Result<String, CommandError> { | ||
execute(command, arguments: []) | ||
} | ||
|
||
func execute(_ command: String, arguments: [String]) -> Result<String, CommandError> { | ||
guard let handler = executeHandler else { | ||
fatalError("executeHandler is nil.") | ||
} | ||
return handler(command, arguments) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters