Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion dist/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -47079,13 +47079,22 @@ function activate(context) {
}
});
});
let atestMockSample = vscode.commands.registerCommand("atest.sampleMock", function(args) {
const wsedit = new vscode.WorkspaceEdit();
const wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
const filePath = vscode.Uri.file(wsPath + "/mock.yaml");
wsedit.createFile(filePath, { ignoreIfExists: true });
wsedit.insert(filePath, new vscode.Position(0, 0), mockSample);
vscode.workspace.applyEdit(wsedit);
vscode.workspace.openTextDocument(filePath);
});
let startMockServerCommand = vscode.commands.registerCommand("atest.startMock", function(args) {
if (vscode.workspace.workspaceFolders !== void 0) {
let filename = vscode.window.activeTextEditor.document.fileName;
atestCodeLenseMock.startMock(filename);
}
});
context.subscriptions.push(atest, atestRunWith, atestSample, startMockServerCommand);
context.subscriptions.push(atest, atestRunWith, atestSample, atestMockSample, startMockServerCommand);
var which = require_lib4();
which("atest", { nothrow: true }).then((p) => {
if (p) {
Expand Down Expand Up @@ -47170,6 +47179,27 @@ function startAtestServer() {
var defaultEnv = `- name: localhost
env:
SERVER: http://localhost:7070`;
var mockSample = `#!api-testing-mock
#!arg --prefix /
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-mock-schema.json
objects:
- name: reports
sample: |
{
"name": "api-testing",
"remark": "",
"taskID": "",
"failedCount": 1,
"color": "{{ randEnum "blue" "read" "pink" }}"
}
items:
- name: base64
request:
path: /v1/base64
response:
body: aGVsbG8=
encoder: base64
`;
function deactivate() {
}
module.exports = {
Expand Down
35 changes: 34 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,25 @@ function activate(context) {
});
})

let atestMockSample = vscode.commands.registerCommand('atest.sampleMock', function(args) {
const wsedit = new vscode.WorkspaceEdit();
const wsPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
const filePath = vscode.Uri.file(wsPath + '/mock.yaml');
wsedit.createFile(filePath, { ignoreIfExists: true });
wsedit.insert(filePath, new vscode.Position(0, 0), mockSample);
vscode.workspace.applyEdit(wsedit);

vscode.workspace.openTextDocument(filePath);
})

let startMockServerCommand = vscode.commands.registerCommand('atest.startMock', function(args) {
if(vscode.workspace.workspaceFolders !== undefined) {
let filename = vscode.window.activeTextEditor.document.fileName
atestCodeLenseMock.startMock(filename)
}
})

context.subscriptions.push(atest, atestRunWith, atestSample, startMockServerCommand);
context.subscriptions.push(atest, atestRunWith, atestSample, atestMockSample, startMockServerCommand);

var which = require('which')
which('atest', { nothrow: true }).then((p) => {
Expand Down Expand Up @@ -289,6 +300,28 @@ const defaultEnv = `- name: localhost
env:
SERVER: http://localhost:7070`

const mockSample = `#!api-testing-mock
#!arg --prefix /
# yaml-language-server: $schema=https://linuxsuren.github.io/api-testing/api-testing-mock-schema.json
objects:
- name: reports
sample: |
{
"name": "api-testing",
"remark": "",
"taskID": "",
"failedCount": 1,
"color": "{{ randEnum "blue" "read" "pink" }}"
}
items:
- name: base64
request:
path: /v1/base64
response:
body: aGVsbG8=
encoder: base64
`

// this method is called when your extension is deactivated
function deactivate() {}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "api-testing",
"displayName": "API Testing",
"description": "YAML based API Testing",
"version": "0.0.16",
"version": "0.0.18",
"repository": "https://github.com/linuxsuren/vscode-api-testing",
"engines": {
"vscode": "^1.68.0"
Expand Down Expand Up @@ -31,6 +31,11 @@
"title": "API Testing Sample",
"description": "Generate an API Testing sample YAML file."
},
{
"command": "atest.sampleMock",
"title": "API Testing Mock Sample",
"description": "Generate a sample mock YAML file."
},
{
"command": "atest.startMock",
"title": "Start API Testing Mock Server"
Expand Down Expand Up @@ -68,6 +73,10 @@
{
"group": "1_run",
"command": "atest.sample"
},
{
"group": "1_run",
"command": "atest.sampleMock"
}
],
"editor/context": [
Expand Down