11import Foundation
2- import XCTest
32import SuggestionModel
3+ import Workspace
4+ import XCTest
45
56@testable import Service
67
78class FilespaceSuggestionInvalidationTests : XCTestCase {
8- @ServiceActor
9+ @WorkspaceActor
910 func prepare( suggestionText: String , cursorPosition: CursorPosition ) async throws -> Filespace {
10- let ( _, filespace) = try await Workspace
11- . fetchOrCreateWorkspaceIfNeeded ( fileURL: URL ( fileURLWithPath: " file/path/to.swift " ) )
11+ let pool = WorkspacePool ( )
12+ let ( _, filespace) = try await pool
13+ . fetchOrCreateWorkspaceAndFilespace ( fileURL: URL ( fileURLWithPath: " file/path/to.swift " ) )
1214 filespace. suggestions = [
1315 . init(
1416 text: suggestionText,
1517 position: cursorPosition,
1618 uuid: " " ,
1719 range: . outOfScope,
1820 displayText: " "
19- )
21+ ) ,
2022 ]
2123 return filespace
2224 }
23-
25+
2426 func test_text_typing_suggestion_should_be_valid( ) async throws {
2527 let filespace = try await prepare (
2628 suggestionText: " hello man " ,
@@ -34,7 +36,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
3436 let suggestion = await filespace. presentingSuggestion
3537 XCTAssertNotNil ( suggestion)
3638 }
37-
39+
3840 func test_text_typing_suggestion_in_the_middle_should_be_valid( ) async throws {
3941 let filespace = try await prepare (
4042 suggestionText: " hello man " ,
@@ -48,7 +50,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
4850 let suggestion = await filespace. presentingSuggestion
4951 XCTAssertNotNil ( suggestion)
5052 }
51-
53+
5254 func test_text_cursor_moved_to_another_line_should_invalidate( ) async throws {
5355 let filespace = try await prepare (
5456 suggestionText: " hello man " ,
@@ -62,7 +64,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
6264 let suggestion = await filespace. presentingSuggestion
6365 XCTAssertNil ( suggestion)
6466 }
65-
67+
6668 func test_text_cursor_is_invalid_should_invalidate( ) async throws {
6769 let filespace = try await prepare (
6870 suggestionText: " hello man " ,
@@ -76,7 +78,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
7678 let suggestion = await filespace. presentingSuggestion
7779 XCTAssertNil ( suggestion)
7880 }
79-
81+
8082 func test_line_content_does_not_match_input_should_invalidate( ) async throws {
8183 let filespace = try await prepare (
8284 suggestionText: " hello man " ,
@@ -90,7 +92,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
9092 let suggestion = await filespace. presentingSuggestion
9193 XCTAssertNil ( suggestion)
9294 }
93-
95+
9496 func test_line_content_does_not_match_input_should_invalidate_index_out_of_scope( ) async throws {
9597 let filespace = try await prepare (
9698 suggestionText: " hello man " ,
@@ -104,7 +106,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
104106 let suggestion = await filespace. presentingSuggestion
105107 XCTAssertNil ( suggestion)
106108 }
107-
109+
108110 func test_finish_typing_the_whole_single_line_suggestion_should_invalidate( ) async throws {
109111 let filespace = try await prepare (
110112 suggestionText: " hello man " ,
@@ -118,8 +120,9 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
118120 let suggestion = await filespace. presentingSuggestion
119121 XCTAssertNil ( suggestion)
120122 }
121-
122- func test_finish_typing_the_whole_single_line_suggestion_suggestion_is_incomplete_should_invalidate( ) async throws {
123+
124+ func test_finish_typing_the_whole_single_line_suggestion_suggestion_is_incomplete_should_invalidate(
125+ ) async throws {
123126 let filespace = try await prepare (
124127 suggestionText: " hello man " ,
125128 cursorPosition: . init( line: 1 , character: 0 )
@@ -132,7 +135,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
132135 let suggestion = await filespace. presentingSuggestion
133136 XCTAssertNil ( suggestion)
134137 }
135-
138+
136139 func test_finish_typing_the_whole_multiple_line_suggestion_should_be_valid( ) async throws {
137140 let filespace = try await prepare (
138141 suggestionText: " hello man \n how are you? " ,
@@ -146,8 +149,9 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
146149 let suggestion = await filespace. presentingSuggestion
147150 XCTAssertNotNil ( suggestion)
148151 }
149-
150- func test_undo_text_to_a_state_before_the_suggestion_was_generated_should_invalidate( ) async throws {
152+
153+ func test_undo_text_to_a_state_before_the_suggestion_was_generated_should_invalidate(
154+ ) async throws {
151155 let filespace = try await prepare (
152156 suggestionText: " hello man " ,
153157 cursorPosition: . init( line: 1 , character: 5 ) // generating man from hello
0 commit comments