Skip to content

Commit 5ea4a34

Browse files
authored
Merge pull request #233 from codecov/fix-no-token-log
fix: Specify log if no token available or empty
2 parents e9cfaf5 + a5ebeb6 commit 5ea4a34

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ async function main(args) {
8686

8787
// == Step 3: sanitize and set token
8888
const token = await tokenHelpers.getToken(inputs, projectRoot)
89+
if (token === '') {
90+
log('-> No token specified or token is empty')
91+
}
8992

9093
// == Step 4: get network
9194
let uploadFile = ''

test/index.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ describe('Uploader Core', () => {
6868
expect(log).toHaveBeenCalledWith(expect.stringMatching(/<<<<<< ENV/))
6969
})
7070

71+
it('Can upload without token', async () => {
72+
jest.spyOn(process, 'exit').mockImplementation(() => {})
73+
const log = jest.spyOn(console, 'log').mockImplementation(() => {})
74+
await app.main({
75+
name: 'customname',
76+
url: 'https://codecov.io',
77+
dryRun: true,
78+
env: 'SOMETHING,ANOTHER',
79+
})
80+
expect(log).toHaveBeenCalledWith(expect.stringMatching('-> No token specified or token is empty'))
81+
})
82+
7183
describe('Flags', () => {
7284
it('can upload with flags', async () => {
7385
process.env.CI = 'true'

0 commit comments

Comments
 (0)