mirror of
https://github.com/usebruno/bruno.git
synced 2025-06-21 20:41:41 +02:00
fix: fixed gql related issues
This commit is contained in:
parent
f69332d9c3
commit
1110a4edda
@ -72,7 +72,7 @@ const bruToJson = (bru) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
transformedJson.request.body.mode = _.get(json, "http.mode", "none");
|
transformedJson.request.body.mode = _.get(json, "http.body", "none");
|
||||||
|
|
||||||
return transformedJson;
|
return transformedJson;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -1,46 +1,50 @@
|
|||||||
class BrunoRequest {
|
class BrunoRequest {
|
||||||
constructor(request) {
|
constructor(req) {
|
||||||
this._request = request;
|
this.req = req;
|
||||||
|
this.url = req.url;
|
||||||
|
this.method = req.method;
|
||||||
|
this.headers = req.headers;
|
||||||
|
this.body = req.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUrl() {
|
getUrl() {
|
||||||
return this._request.url;
|
return this.req.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUrl(url) {
|
setUrl(url) {
|
||||||
this._request.url = url;
|
this.req.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMethod() {
|
getMethod() {
|
||||||
return this._request.method;
|
return this.req.method;
|
||||||
}
|
}
|
||||||
|
|
||||||
setMethod(method) {
|
setMethod(method) {
|
||||||
this._request.method = method;
|
this.req.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeaders() {
|
getHeaders() {
|
||||||
return this._request.headers;
|
return this.req.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
setHeaders(headers) {
|
setHeaders(headers) {
|
||||||
this._request.headers = headers;
|
this.req.headers = headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeader(name) {
|
getHeader(name) {
|
||||||
return this._request.headers[name];
|
return this.req.headers[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
setHeader(name, value) {
|
setHeader(name, value) {
|
||||||
this._request.headers[name] = value;
|
this.req.headers[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBody() {
|
getBody() {
|
||||||
return this._request.data;
|
return this.req.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
setBody(data) {
|
setBody(data) {
|
||||||
this._request.data = data;
|
this.req.data = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
class BrunoResponse {
|
class BrunoResponse {
|
||||||
constructor(response) {
|
constructor(res) {
|
||||||
this._response = response;
|
this.res = res;
|
||||||
this.status = response.status;
|
this.status = res.status;
|
||||||
this.statusText = response.statusText;
|
this.statusText = res.statusText;
|
||||||
this.headers = response.headers;
|
this.headers = res.headers;
|
||||||
this.body = response.data;
|
this.body = res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatus() {
|
getStatus() {
|
||||||
return this._response.status;
|
return this.res.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeader(name) {
|
getHeader(name) {
|
||||||
return this._response.header[name];
|
return this.res.header[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeaders() {
|
getHeaders() {
|
||||||
return this._response.headers;
|
return this.res.headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getBody() {
|
getBody() {
|
||||||
return this._response.data;
|
return this.res.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,12 @@ class ScriptRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runRequestScript(script, request, environment, collectionVariables, collectionPath) {
|
runRequestScript(script, request, environment, collectionVariables, collectionPath) {
|
||||||
const $bru = new Bru(environment, collectionVariables);
|
const bru = new Bru(environment, collectionVariables);
|
||||||
const $req = new BrunoRequest(request);
|
const req = new BrunoRequest(request);
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
$bru,
|
bru,
|
||||||
$req
|
req
|
||||||
};
|
};
|
||||||
const vm = new NodeVM({
|
const vm = new NodeVM({
|
||||||
sandbox: context,
|
sandbox: context,
|
||||||
@ -53,12 +53,12 @@ class ScriptRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runResponseScript(script, response, environment, collectionVariables, collectionPath) {
|
runResponseScript(script, response, environment, collectionVariables, collectionPath) {
|
||||||
const $bru = new Bru(environment, collectionVariables);
|
const bru = new Bru(environment, collectionVariables);
|
||||||
const $res = new BrunoResponse(response);
|
const res = new BrunoResponse(response);
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
$bru,
|
bru,
|
||||||
$res
|
res
|
||||||
};
|
};
|
||||||
const vm = new NodeVM({
|
const vm = new NodeVM({
|
||||||
sandbox: context,
|
sandbox: context,
|
||||||
|
@ -21,18 +21,18 @@ class TestRuntime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runTests(testsFile, request, response, environment, collectionVariables, collectionPath) {
|
runTests(testsFile, request, response, environment, collectionVariables, collectionPath) {
|
||||||
const $bru = new Bru(environment, collectionVariables);
|
const bru = new Bru(environment, collectionVariables);
|
||||||
const $req = new BrunoRequest(request);
|
const req = new BrunoRequest(request);
|
||||||
const $res = new BrunoResponse(response);
|
const res = new BrunoResponse(response);
|
||||||
|
|
||||||
const __brunoTestResults = new TestResults();
|
const __brunoTestResults = new TestResults();
|
||||||
const test = Test(__brunoTestResults, chai);
|
const test = Test(__brunoTestResults, chai);
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
test,
|
test,
|
||||||
$bru,
|
bru,
|
||||||
$req,
|
req,
|
||||||
$res,
|
res,
|
||||||
expect: chai.expect,
|
expect: chai.expect,
|
||||||
assert: chai.assert,
|
assert: chai.assert,
|
||||||
__brunoTestResults: __brunoTestResults
|
__brunoTestResults: __brunoTestResults
|
||||||
|
@ -42,9 +42,9 @@ const jsonToBru = (json) => {
|
|||||||
bru += `${http.method} {
|
bru += `${http.method} {
|
||||||
url: ${http.url}`;
|
url: ${http.url}`;
|
||||||
|
|
||||||
if(http.body && http.body.length) {
|
if(http.mode && http.mode.length) {
|
||||||
bru += `
|
bru += `
|
||||||
body: ${http.body}`;
|
body: ${http.mode}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
bru += `
|
bru += `
|
||||||
|
Loading…
x
Reference in New Issue
Block a user