mirror of
https://github.com/codecov/codecov-action.git
synced 2026-02-13 14:37:24 +00:00
test: fix tests
This commit is contained in:
parent
0c23ec5ce3
commit
f1d218aabf
3 changed files with 35 additions and 3 deletions
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
|
@ -5,6 +5,7 @@ import {
|
||||||
buildGeneralExec,
|
buildGeneralExec,
|
||||||
buildReportExec,
|
buildReportExec,
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
|
getToken,
|
||||||
} from './buildExec';
|
} from './buildExec';
|
||||||
|
|
||||||
const context = github.context;
|
const context = github.context;
|
||||||
|
|
@ -280,6 +281,12 @@ test('commit args using context', async () => {
|
||||||
if (context.eventName == 'pull_request') {
|
if (context.eventName == 'pull_request') {
|
||||||
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
(context.eventName == 'pull_request' || context.eventName == 'pull_request_target') &&
|
||||||
|
context.payload.pull_request?.base.label.split(':')[0] != context.payload.pull_request?.head.label.split(':')[0]
|
||||||
|
) {
|
||||||
|
expectedArgs.push('-B', `${context.payload.pull_request?.head.label}`);
|
||||||
|
}
|
||||||
if (context.eventName == 'pull_request_target') {
|
if (context.eventName == 'pull_request_target') {
|
||||||
expectedArgs.push('-P', `${context.payload.number}`);
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
}
|
||||||
|
|
@ -300,15 +307,20 @@ test('commit args using github server url', async () => {
|
||||||
if (context.eventName == 'pull_request') {
|
if (context.eventName == 'pull_request') {
|
||||||
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
expectedArgs.push('-C', `${context.payload.pull_request?.head.sha}`);
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
(context.eventName == 'pull_request' || context.eventName == 'pull_request_target') &&
|
||||||
|
context.payload.pull_request?.base.label.split(':')[0] != context.payload.pull_request?.head.label.split(':')[0]
|
||||||
|
) {
|
||||||
|
expectedArgs.push('-B', `${context.payload.pull_request?.head.label}`);
|
||||||
|
}
|
||||||
if (context.eventName == 'pull_request_target') {
|
if (context.eventName == 'pull_request_target') {
|
||||||
expectedArgs.push('-P', `${context.payload.number}`);
|
expectedArgs.push('-P', `${context.payload.number}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(commitExecArgs).toEqual(expectedArgs);
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get token when token arg is unset and from fork', async () => {
|
test('build commit args when token arg is unset and from fork', async () => {
|
||||||
context.eventName = 'pull_request';
|
context.eventName = 'pull_request';
|
||||||
context.payload.pull_request = {
|
context.payload.pull_request = {
|
||||||
'number': 1,
|
'number': 1,
|
||||||
|
|
@ -335,3 +347,22 @@ test('get token when token arg is unset and from fork', async () => {
|
||||||
expect(commitExecArgs).toEqual(expectedArgs);
|
expect(commitExecArgs).toEqual(expectedArgs);
|
||||||
expect(commitCommand).toEqual('create-commit');
|
expect(commitCommand).toEqual('create-commit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('get token when token arg is unset and from fork', async () => {
|
||||||
|
context.eventName = 'pull_request';
|
||||||
|
context.payload.pull_request = {
|
||||||
|
'number': 1,
|
||||||
|
'base': {
|
||||||
|
'label': 'hello:main',
|
||||||
|
},
|
||||||
|
'head': {
|
||||||
|
'label': 'world:feat',
|
||||||
|
'sha': 'aaaaaa',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const token = await getToken();
|
||||||
|
|
||||||
|
expect(token).toEqual(null);
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -412,4 +412,5 @@ export {
|
||||||
buildGeneralExec,
|
buildGeneralExec,
|
||||||
buildReportExec,
|
buildReportExec,
|
||||||
buildUploadExec,
|
buildUploadExec,
|
||||||
|
getToken,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue