Skip to content

Commit 7c6dd08

Browse files
committed
Fix tests
1 parent 92a58b4 commit 7c6dd08

File tree

4 files changed

+37
-14
lines changed

4 files changed

+37
-14
lines changed

Core/Tests/SuggestionServiceTests/CodeSplitAtCursorTests.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import Shared
2+
import Fundamental
33
import XCTest
44

55
@testable import SuggestionService
@@ -16,14 +16,13 @@ class CodeSplitAtCursorTests: XCTestCase {
1616
}
1717
"""
1818
let lines = code.breakLines()
19-
let (previousLines, nextLines, prefix) = Service.split(
19+
let (previousLines, nextLines) = Service.split(
2020
code: code,
2121
lines: lines,
2222
at: .init(line: 6, character: 1)
2323
)
2424
XCTAssertEqual(previousLines, lines)
2525
XCTAssertEqual(nextLines, [])
26-
XCTAssertEqual(prefix, "}")
2726
}
2827

2928
func test_split_in_the_middle() {
@@ -37,14 +36,13 @@ class CodeSplitAtCursorTests: XCTestCase {
3736
}
3837
"""
3938
let lines = code.breakLines()
40-
let (previousLines, nextLines, prefix) = Service.split(
39+
let (previousLines, nextLines) = Service.split(
4140
code: code,
4241
lines: lines,
4342
at: .init(line: 2, character: 14)
4443
)
4544
XCTAssertEqual(previousLines, Array(lines[0...1]) + [" let middle"])
4645
XCTAssertEqual(nextLines, [" = array.count / 2\n"] + Array(lines[3...]))
47-
XCTAssertEqual(prefix, " let middle")
4846
}
4947

5048
func test_split_right_before_line_break() {
@@ -58,27 +56,25 @@ class CodeSplitAtCursorTests: XCTestCase {
5856
}
5957
"""
6058
let lines = code.breakLines()
61-
let (previousLines, nextLines, prefix) = Service.split(
59+
let (previousLines, nextLines) = Service.split(
6260
code: code,
6361
lines: lines,
6462
at: .init(line: 2, character: 32)
6563
)
6664
XCTAssertEqual(previousLines, Array(lines[0...1]) + [" let middle = array.count / 2"])
6765
XCTAssertEqual(nextLines, ["\n"] + Array(lines[3...]))
68-
XCTAssertEqual(prefix, " let middle")
6966
}
7067

7168
func test_split_empty_file() {
7269
let code = ""
7370
let lines = code.breakLines()
74-
let (previousLines, nextLines, prefix) = Service.split(
71+
let (previousLines, nextLines) = Service.split(
7572
code: code,
7673
lines: lines,
7774
at: .init(line: 0, character: 0)
7875
)
7976
XCTAssertEqual(previousLines, [])
8077
XCTAssertEqual(nextLines, [])
81-
XCTAssertEqual(prefix, "")
8278
}
8379

8480
func test_split_at_out_of_scope_position() {
@@ -92,14 +88,13 @@ class CodeSplitAtCursorTests: XCTestCase {
9288
}
9389
"""
9490
let lines = code.breakLines()
95-
let (previousLines, nextLines, prefix) = Service.split(
91+
let (previousLines, nextLines) = Service.split(
9692
code: code,
9793
lines: lines,
9894
at: .init(line: lines.endIndex, character: 0)
9995
)
10096
XCTAssertEqual(previousLines, lines)
10197
XCTAssertEqual(nextLines, [])
102-
XCTAssertEqual(prefix, "")
10398
}
10499
}
105100

Core/Tests/SuggestionServiceTests/DefaultRequestStrategyTests.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Foundation
2-
import Shared
2+
import Fundamental
33
import XCTest
44

55
@testable import SuggestionService
@@ -27,7 +27,8 @@ class DefaultRequestStrategyTests: XCTestCase {
2727

2828
guard let (summary, infillBlock) = DefaultRequestStrategy.Prompt.createCodeSummary(
2929
truncatedPrefix: prefix.breakLines(),
30-
truncatedSuffix: []
30+
truncatedSuffix: [],
31+
suggestionPrefix: "let cat:"
3132
) else {
3233
XCTFail()
3334
return
@@ -87,7 +88,8 @@ class DefaultRequestStrategyTests: XCTestCase {
8788

8889
guard let (summary, infillBlock) = DefaultRequestStrategy.Prompt.createCodeSummary(
8990
truncatedPrefix: prefix.breakLines(),
90-
truncatedSuffix: suffix.breakLines()
91+
truncatedSuffix: suffix.breakLines(),
92+
suggestionPrefix: "let cat:"
9193
) else {
9294
XCTFail()
9395
return

CustomSuggestionService.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
C8EA62D22B6BE4AC00E081FC /* BaseURLSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseURLSelection.swift; sourceTree = "<group>"; };
104104
C8EA62D42B6BE4BE00E081FC /* Toast.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Toast.swift; sourceTree = "<group>"; };
105105
C8F0E4BA2B872B61004B45FB /* Core */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Core; sourceTree = "<group>"; };
106+
C8F0E4BF2B872F9D004B45FB /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
106107
/* End PBXFileReference section */
107108

108109
/* Begin PBXFrameworksBuildPhase section */
@@ -153,6 +154,7 @@
153154
C84794A82B86EC6100483DF4 /* Version.xcconfig */,
154155
C8D0115A2B5A59D100219412 /* Config.xcconfig */,
155156
C8D0115B2B5A59D400219412 /* Config.debug.xcconfig */,
157+
C8F0E4BF2B872F9D004B45FB /* TestPlan.xctestplan */,
156158
C8F0E4BA2B872B61004B45FB /* Core */,
157159
C8D0114A2B59912700219412 /* CustomSuggestionService */,
158160
C8D011612B5A5B4D00219412 /* CopilotForXcodeExtension */,

TestPlan.xctestplan

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"configurations" : [
3+
{
4+
"id" : "2CD745CA-E543-4414-9155-E331D21582A0",
5+
"name" : "Configuration 1",
6+
"options" : {
7+
8+
}
9+
}
10+
],
11+
"defaultOptions" : {
12+
"testTimeoutsEnabled" : true
13+
},
14+
"testTargets" : [
15+
{
16+
"target" : {
17+
"containerPath" : "container:Core",
18+
"identifier" : "SuggestionServiceTests",
19+
"name" : "SuggestionServiceTests"
20+
}
21+
}
22+
],
23+
"version" : 1
24+
}

0 commit comments

Comments
 (0)