Skip to content

Commit ab0ccf7

Browse files
committed
Fix broken tests
1 parent 0945ba9 commit ab0ccf7

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

Core/Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ let package = Package(
269269
"LanguageClient",
270270
"SuggestionModel",
271271
"XPCShared",
272+
.product(name: "Logger", package: "Tool"),
272273
.product(name: "Preferences", package: "Tool"),
273274
.product(name: "Terminal", package: "Tool"),
274275
]

Core/Sources/SuggestionModel/LanguageIdentifierFromFilePath.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum CodeLanguage: RawRepresentable, Codable, CaseIterable, Hashable {
1616
return language
1717
}
1818
}
19-
19+
2020
public var hashValue: Int {
2121
rawValue.hashValue
2222
}
@@ -30,15 +30,15 @@ public enum CodeLanguage: RawRepresentable, Codable, CaseIterable, Hashable {
3030
self = .other(rawValue)
3131
}
3232
}
33-
33+
3434
public static var allCases: [CodeLanguage] {
3535
var all = LanguageIdentifier.allCases.map(CodeLanguage.builtIn)
3636
all.append(.plaintext)
3737
return all
3838
}
3939
}
4040

41-
extension LanguageIdentifier {
41+
public extension LanguageIdentifier {
4242
/// Copied from https://github.com/github/linguist/blob/master/lib/linguist/languages.yml [MIT]
4343
var fileExtensions: [String] {
4444
switch self {
@@ -263,3 +263,4 @@ public func languageIdentifierFromFileURL(_ fileURL: URL) -> CodeLanguage {
263263
}
264264
return .init(rawValue: fileExtension) ?? .plaintext
265265
}
266+

Core/Tests/GitHubCopilotServiceTests/FetchSuggestionsTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ final class FetchSuggestionTests: XCTestCase {
103103
}
104104

105105
class TestServer: GitHubCopilotLSP {
106+
func sendNotification(_ notif: LanguageServerProtocol.ClientNotification) async throws {
107+
// unimplemented
108+
}
109+
106110
func sendRequest<E>(_ r: E) async throws -> E.Response where E: GitHubCopilotRequestType {
107111
return GitHubCopilotRequest.GetCompletionsCycling.Response(completions: [
108112
.init(

TestPlan.xctestplan

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,50 +25,57 @@
2525
{
2626
"target" : {
2727
"containerPath" : "container:Core",
28-
"identifier" : "CopilotModelTests",
29-
"name" : "CopilotModelTests"
28+
"identifier" : "ServiceTests",
29+
"name" : "ServiceTests"
3030
}
3131
},
3232
{
3333
"target" : {
3434
"containerPath" : "container:Core",
35-
"identifier" : "CopilotServiceTests",
36-
"name" : "CopilotServiceTests"
35+
"identifier" : "SuggestionInjectorTests",
36+
"name" : "SuggestionInjectorTests"
3737
}
3838
},
3939
{
4040
"target" : {
4141
"containerPath" : "container:Core",
42-
"identifier" : "ServiceTests",
43-
"name" : "ServiceTests"
42+
"identifier" : "SuggestionWidgetTests",
43+
"name" : "SuggestionWidgetTests"
4444
}
4545
},
4646
{
4747
"target" : {
4848
"containerPath" : "container:Core",
49-
"identifier" : "SuggestionInjectorTests",
50-
"name" : "SuggestionInjectorTests"
49+
"identifier" : "PromptToCodeServiceTests",
50+
"name" : "PromptToCodeServiceTests"
5151
}
5252
},
5353
{
5454
"target" : {
5555
"containerPath" : "container:Core",
56-
"identifier" : "OpenAIServiceTests",
57-
"name" : "OpenAIServiceTests"
56+
"identifier" : "GitHubCopilotServiceTests",
57+
"name" : "GitHubCopilotServiceTests"
5858
}
5959
},
6060
{
6161
"target" : {
6262
"containerPath" : "container:Core",
63-
"identifier" : "SuggestionWidgetTests",
64-
"name" : "SuggestionWidgetTests"
63+
"identifier" : "SuggestionModelTests",
64+
"name" : "SuggestionModelTests"
6565
}
6666
},
6767
{
6868
"target" : {
69-
"containerPath" : "container:Core",
70-
"identifier" : "PromptToCodeServiceTests",
71-
"name" : "PromptToCodeServiceTests"
69+
"containerPath" : "container:Tool",
70+
"identifier" : "LangChainTests",
71+
"name" : "LangChainTests"
72+
}
73+
},
74+
{
75+
"target" : {
76+
"containerPath" : "container:Tool",
77+
"identifier" : "OpenAIServiceTests",
78+
"name" : "OpenAIServiceTests"
7279
}
7380
}
7481
],

Tool/Tests/OpenAIServiceTests/ChatGPTServiceTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ final class ChatGPTServiceTests: XCTestCase {
4545
requestBody = _requestBody
4646
return MockCompletionStreamAPI_Success()
4747
}
48+
await service.mutateSystemPrompt("system")
4849
let stream = try await service.send(content: "Hello")
4950
var all = [String]()
5051
for try await text in stream {
@@ -58,7 +59,7 @@ final class ChatGPTServiceTests: XCTestCase {
5859
}
5960

6061
XCTAssertEqual(requestBody?.messages, [
61-
.init(role: .system, content: ""),
62+
.init(role: .system, content: "system"),
6263
.init(role: .user, content: "Hello"),
6364
], "System prompt is included")
6465
XCTAssertEqual(all, ["hello", "my", "friends"], "Text stream is correct")

0 commit comments

Comments
 (0)