1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-16 00:20:06 +00:00

fix: computeApi debug override

This commit is contained in:
Mihajlo Medjedovic
2020-11-24 15:19:19 +01:00
parent e36b511530
commit 011e2d83dc
5 changed files with 21 additions and 21 deletions

View File

@@ -1,9 +0,0 @@
import React from "react";
import { render } from "@testing-library/react";
import App from "./App";
test("renders learn react link", () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@@ -3,12 +3,12 @@ import { TestSuite } from "@sasjs/test-framework";
const defaultConfig: SASjsConfig = { const defaultConfig: SASjsConfig = {
serverUrl: window.location.origin, serverUrl: window.location.origin,
pathSAS9: "/SASStoredProcess/do", pathSAS9: '/SASStoredProcess/do',
pathSASViya: "/SASJobExecution", pathSASViya: '/SASJobExecution',
appLoc: "/Public/seedapp", appLoc: '/Public/seedapp',
serverType: ServerType.SASViya, serverType: ServerType.SASViya,
debug: true, debug: false,
contextName: "SAS Job Execution compute context", contextName: 'SAS Job Execution compute context',
useComputeApi: false useComputeApi: false
}; };
@@ -57,6 +57,7 @@ export const basicTests = (
}, },
assertion: (sasjsInstance: SASjs) => { assertion: (sasjsInstance: SASjs) => {
const sasjsConfig = sasjsInstance.getSasjsConfig(); const sasjsConfig = sasjsInstance.getSasjsConfig();
return ( return (
sasjsConfig.serverUrl === defaultConfig.serverUrl && sasjsConfig.serverUrl === defaultConfig.serverUrl &&
sasjsConfig.pathSAS9 === defaultConfig.pathSAS9 && sasjsConfig.pathSAS9 === defaultConfig.pathSAS9 &&

View File

@@ -23,7 +23,7 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
}, },
{ {
title: "Make error and capture log", title: "Make error and capture log",
description: "Should make an error and capture log", description: "Should make an error and capture log, in the same time it is testing if debug override is working",
test: async () => { test: async () => {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
adapter adapter
@@ -33,12 +33,14 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({
}) })
.catch((err) => { .catch((err) => {
let sasRequests = adapter.getSasRequests(); let sasRequests = adapter.getSasRequests();
let makeErrRequest = let makeErrRequest: any =
sasRequests.find((req) => sasRequests.find((req) =>
req.serviceLink.includes("makeErr") req.serviceLink.includes("makeErr")
) || null; ) || null;
resolve(!!makeErrRequest); if (!makeErrRequest) resolve(false)
resolve(!!(makeErrRequest.logFile && makeErrRequest.logFile.length > 0));
}); });
}); });
}, },

View File

@@ -426,10 +426,10 @@ export class SASViyaApiClient {
* @param linesOfCode - an array of code lines to execute. * @param linesOfCode - an array of code lines to execute.
* @param contextName - the context to execute the code in. * @param contextName - the context to execute the code in.
* @param accessToken - an access token for an authorized user. * @param accessToken - an access token for an authorized user.
* @param sessionId - optional session ID to reuse.
* @param data - execution data. * @param data - execution data.
* @param debug - when set to true, the log will be returned. * @param debug - when set to true, the log will be returned.
* @param expectWebout - when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code). * @param expectWebout - when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code).
* @param waitForResult - when set to true, function will return the session
*/ */
public async executeScript( public async executeScript(
jobPath: string, jobPath: string,
@@ -437,6 +437,7 @@ export class SASViyaApiClient {
contextName: string, contextName: string,
accessToken?: string, accessToken?: string,
data = null, data = null,
debug: boolean = false,
expectWebout = false, expectWebout = false,
waitForResult = true waitForResult = true
): Promise<any> { ): Promise<any> {
@@ -467,7 +468,7 @@ export class SASViyaApiClient {
_OMITTEXTLOG: true _OMITTEXTLOG: true
} }
if (this.debug) { if (debug) {
jobArguments['_OMITTEXTLOG'] = false jobArguments['_OMITTEXTLOG'] = false
jobArguments['_OMITSESSIONRESULTS'] = false jobArguments['_OMITSESSIONRESULTS'] = false
jobArguments['_DEBUG'] = 131 jobArguments['_DEBUG'] = 131
@@ -535,7 +536,7 @@ export class SASViyaApiClient {
return session return session
} }
if (this.debug) { if (debug) {
console.log(`Job has been submitted for '${fileName}'.`) console.log(`Job has been submitted for '${fileName}'.`)
console.log( console.log(
`You can monitor the job progress at '${this.serverUrl}${ `You can monitor the job progress at '${this.serverUrl}${
@@ -558,7 +559,7 @@ export class SASViyaApiClient {
const logLink = currentJob.links.find((l) => l.rel === 'log') const logLink = currentJob.links.find((l) => l.rel === 'log')
if (this.debug && logLink) { if (debug && logLink) {
log = await this.request<any>( log = await this.request<any>(
`${this.serverUrl}${logLink.href}/content?limit=10000`, `${this.serverUrl}${logLink.href}/content?limit=10000`,
{ {
@@ -633,6 +634,7 @@ export class SASViyaApiClient {
contextName, contextName,
accessToken, accessToken,
data, data,
debug,
false, false,
true true
) )
@@ -953,6 +955,7 @@ export class SASViyaApiClient {
public async executeComputeJob( public async executeComputeJob(
sasJob: string, sasJob: string,
contextName: string, contextName: string,
debug?: boolean,
data?: any, data?: any,
accessToken?: string, accessToken?: string,
waitForResult = true, waitForResult = true,
@@ -1039,6 +1042,7 @@ export class SASViyaApiClient {
contextName, contextName,
accessToken, accessToken,
data, data,
debug,
expectWebout, expectWebout,
waitForResult waitForResult
) )

View File

@@ -734,6 +734,7 @@ export default class SASjs {
return this.sasViyaApiClient?.executeComputeJob( return this.sasViyaApiClient?.executeComputeJob(
sasJob, sasJob,
config.contextName, config.contextName,
config.debug,
data, data,
accessToken, accessToken,
!!waitForResult, !!waitForResult,
@@ -766,6 +767,7 @@ export default class SASjs {
?.executeComputeJob( ?.executeComputeJob(
sasJob, sasJob,
config.contextName, config.contextName,
config.debug,
data, data,
accessToken, accessToken,
waitForResult, waitForResult,