-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: get language information (#6109)
- Loading branch information
Showing
6 changed files
with
117 additions
and
54 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
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
40 changes: 0 additions & 40 deletions
40
vscode/microsoft-kiota/src/commands/generate/getLanguageInformation.ts
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
vscode/microsoft-kiota/src/kiotaInterop/languageInformation.ts
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,33 @@ | ||
import * as rpc from "vscode-jsonrpc/node"; | ||
|
||
import { LanguagesInformation } from "."; | ||
import connectToKiota from "./connect"; | ||
|
||
interface LanguageInformationConfiguration { | ||
descriptionUrl: string; clearCache: boolean; | ||
} | ||
|
||
export function getLanguageInformationInternal(): Promise<LanguagesInformation | undefined> { | ||
return connectToKiota<LanguagesInformation>(async (connection) => { | ||
const request = new rpc.RequestType0<LanguagesInformation, void>( | ||
"Info" | ||
); | ||
return await connection.sendRequest( | ||
request, | ||
); | ||
}); | ||
}; | ||
|
||
export function getLanguageInformationForDescription({ descriptionUrl, clearCache }: LanguageInformationConfiguration): | ||
Promise<LanguagesInformation | undefined> { | ||
return connectToKiota<LanguagesInformation>(async (connection) => { | ||
const request = new rpc.RequestType2<string, boolean, LanguagesInformation, void>( | ||
"InfoForDescription" | ||
); | ||
return await connection.sendRequest( | ||
request, | ||
descriptionUrl, | ||
clearCache | ||
); | ||
}); | ||
}; |
54 changes: 54 additions & 0 deletions
54
vscode/microsoft-kiota/src/kiotaInterop/tests/languageInformation.spec.ts
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,54 @@ | ||
import * as sinon from 'sinon'; | ||
|
||
|
||
import { setupKiotaStubs } from './stubs.util'; | ||
import { getLanguageInformationForDescription, getLanguageInformationInternal } from '../languageInformation'; | ||
|
||
const sampleLanguageInfo = { | ||
CSharp: { | ||
MaturityLevel: 2, | ||
SupportExperience: 0, | ||
Dependencies: [ | ||
{ | ||
Name: "Microsoft.Kiota.Abstractions", | ||
Version: "1.16.4", | ||
DependencyType: 0, | ||
} | ||
], | ||
DependencyInstallCommand: "dotnet add package {0} --version {1}", | ||
ClientClassName: "", | ||
ClientNamespaceName: "", | ||
StructuredMimeTypes: [ | ||
], | ||
} | ||
}; | ||
|
||
describe("Language Information", () => { | ||
let connectionStub: sinon.SinonStub; | ||
|
||
beforeEach(() => { | ||
const stubs = setupKiotaStubs(); | ||
connectionStub = stubs.connectionStub; | ||
}); | ||
|
||
afterEach(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
|
||
test('should return language information for a description when successful', async () => { | ||
const mockResults = sampleLanguageInfo; | ||
connectionStub.resolves(mockResults); | ||
const results = await getLanguageInformationForDescription({ clearCache: false, descriptionUrl: 'test.com' }); | ||
expect(results).toBeDefined(); | ||
}); | ||
|
||
test('should return internal language information when successful', async () => { | ||
const mockResults = sampleLanguageInfo; | ||
|
||
connectionStub.resolves(mockResults); | ||
const results = await getLanguageInformationInternal(); | ||
expect(results).toBeDefined(); | ||
}); | ||
|
||
}); |
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