Skip to content

Commit 3644861

Browse files
code refactor
1 parent 4877bc7 commit 3644861

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

SwiftUIExamples/SwiftUIExamplesTests/git_hub_repos_async_tests.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ final class GitHubReposAsyncTests: XCTestCase {
2020
throw FakeError()
2121
}
2222
}
23-
23+
24+
class InvalidUsernameService: GitHubServiceProtocol {
25+
func fetchRepos(for username: String) async throws -> [GitHubRepo] {
26+
throw GitHubServiceError.invalidURL
27+
}
28+
}
29+
2430
func testLoadRepos_Success() async throws {
2531
let viewModel = RepoListViewModel(service: MockSuccessService())
2632
await viewModel.loadRepos(for: "janeshsutharios")
@@ -70,11 +76,6 @@ final class GitHubReposAsyncTests: XCTestCase {
7076
}
7177

7278
func testLoadRepos_InvalidUsername() async throws {
73-
struct InvalidUsernameService: GitHubServiceProtocol {
74-
func fetchRepos(for username: String) async throws -> [GitHubRepo] {
75-
throw GitHubServiceError.invalidURL
76-
}
77-
}
7879

7980
let viewModel = RepoListViewModel(service: InvalidUsernameService())
8081
await viewModel.loadRepos(for: "invalid@@@username")

0 commit comments

Comments
 (0)