This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
--body
supports reading from STDIN (#23)
If you do `flag.allowStdin: true` then oclif will read from stdin for you if the value is `-`, so there's no way to know if the flag value came from stdin or the user specified a file path (here we need to read the file). I don't like having another specific flag just to read from stdin so I made this a string flag and handle reading from stdin/file in `flag.parse`. also: * made `got` not follow redirects (use `--include` flag and check the `Location` header if need that). * bumped deps
- Loading branch information
1 parent
0941d9c
commit 06ef90d
Showing
5 changed files
with
2,072 additions
and
762 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import nock = require('nock'); | ||
import { TestContext, MockTestOrgData } from '@salesforce/core/lib/testSetup.js'; | ||
import { | ||
TestContext, | ||
MockTestOrgData, | ||
} from '@salesforce/core/lib/testSetup.js'; | ||
import { SfError } from '@salesforce/core'; | ||
import { expect } from 'chai'; | ||
import stripAnsi from 'strip-ansi'; | ||
|
@@ -13,6 +16,13 @@ describe('org api', () => { | |
|
||
let stdoutSpy: sinon.SinonSpy; | ||
|
||
const orgLimitsResponse = { | ||
ActiveScratchOrgs: { | ||
Max: 200, | ||
Remaining: 199, | ||
}, | ||
}; | ||
|
||
beforeEach(async () => { | ||
await $$.stubAuths(testOrg); | ||
stdoutSpy = $$.SANDBOX.stub(process.stdout, 'write'); | ||
|
@@ -23,13 +33,6 @@ describe('org api', () => { | |
}); | ||
|
||
it('should request org limits and default to "GET" HTTP method', async () => { | ||
const orgLimitsResponse = { | ||
ActiveScratchOrgs: { | ||
Max: 200, | ||
Remaining: 199, | ||
}, | ||
}; | ||
|
||
nock(testOrg.instanceUrl) | ||
.get('/services/data/v56.0/limits') | ||
.reply(200, orgLimitsResponse); | ||
|
@@ -98,4 +101,22 @@ describe('org api', () => { | |
); | ||
} | ||
}); | ||
|
||
it('should not follow redirects', async () => { | ||
nock(testOrg.instanceUrl) | ||
.get('/services/data/v56.0/limites') | ||
.reply(301, orgLimitsResponse, { | ||
location: `${testOrg.instanceUrl}/services/data/v56.0/limits`, | ||
}); | ||
|
||
await OrgApi.run([ | ||
'services/data/v56.0/limites', | ||
'--target-org', | ||
'[email protected]', | ||
]); | ||
|
||
const output = stripAnsi(stdoutSpy.args.flat().join('')); | ||
|
||
expect(JSON.parse(output)).to.deep.equal(orgLimitsResponse); | ||
}); | ||
}); |
Oops, something went wrong.