Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): fixed verbose mode in getSASjs utility #1363

Merged
merged 2 commits into from
Aug 4, 2023
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
4 changes: 3 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@ export const getTestTearDown = async (target: Target) => {
* @returns - instance of @sasjs/adapter.
*/
export function getSASjs(target: Target) {
const verbose = process.env.VERBOSE

return new SASjs({
serverUrl: target.serverUrl,
appLoc: target.appLoc,
Expand All @@ -966,7 +968,7 @@ export function getSASjs(target: Target) {
httpsAgentOptions: target.httpsAgentOptions,
debug: true,
useComputeApi: target.serverType === ServerType.SasViya, // compute api is used only on Viya server
verbose: !!process.env.VERBOSE // any not empty string should be considered as true
verbose: typeof verbose === 'string' ? /on/i.test(verbose) : false // only string equal to 'on'(case insensitive) will enable verbose mode
})
}

Expand Down
26 changes: 22 additions & 4 deletions src/utils/spec/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,20 @@ describe('getSASjs', () => {
expect(useComputeApi).toEqual(false)
})

it('should enable verbose mode if VERBOSE env is present', () => {
it(`should enable verbose mode if VERBOSE env is present and is equal to 'on'(case insensitive)`, () => {
process.env.VERBOSE = 'on'

const sasjs = getSASjs({} as Target)
const sasjsConfig = sasjs.getSasjsConfig()
const { verbose } = sasjsConfig
let sasjs = getSASjs({} as Target)
let sasjsConfig = sasjs.getSasjsConfig()
let { verbose } = sasjsConfig

expect(verbose).toEqual(true)

process.env.VERBOSE = 'ON'

sasjs = getSASjs({} as Target)
sasjsConfig = sasjs.getSasjsConfig()
verbose = sasjsConfig.verbose

expect(verbose).toEqual(true)
})
Expand All @@ -575,4 +583,14 @@ describe('getSASjs', () => {

expect(verbose).toEqual(false)
})

it(`should disable verbose mode if VERBOSE env is present and is not equal to 'on'(case insensitive)`, () => {
process.env.VERBOSE = 'start'

const sasjs = getSASjs({} as Target)
const sasjsConfig = sasjs.getSasjsConfig()
const { verbose } = sasjsConfig

expect(verbose).toEqual(false)
})
})