mirror of
https://github.com/github/codeql-action.git
synced 2025-12-22 15:20:19 +08:00
Clean up the database if it will be uploaded
This commit is contained in:
@@ -69,6 +69,17 @@ async function mockHttpRequests(databaseUploadStatusCode: number) {
|
||||
return databaseUploadSpy;
|
||||
}
|
||||
|
||||
function getCodeQL() {
|
||||
return setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
fs.writeFileSync(outputFilePath, "");
|
||||
},
|
||||
async databaseCleanupCluster() {
|
||||
// Do nothing, as we are not testing cleanup here.
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
test("Abort database upload if 'upload-database' input set to false", async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
@@ -81,6 +92,7 @@ test("Abort database upload if 'upload-database' input set to false", async (t)
|
||||
const loggedMessages = [];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
getTestConfig(tmpDir),
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages),
|
||||
@@ -111,6 +123,7 @@ test("Abort database upload if running against GHES", async (t) => {
|
||||
const loggedMessages = [];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
config,
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages),
|
||||
@@ -138,6 +151,7 @@ test("Abort database upload if not analyzing default branch", async (t) => {
|
||||
const loggedMessages = [];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
getTestConfig(tmpDir),
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages),
|
||||
@@ -163,15 +177,10 @@ test("Don't crash if uploading a database fails", async (t) => {
|
||||
|
||||
await mockHttpRequests(500);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
fs.writeFileSync(outputFilePath, "");
|
||||
},
|
||||
});
|
||||
|
||||
const loggedMessages = [] as LoggedMessage[];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
getTestConfig(tmpDir),
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages),
|
||||
@@ -199,15 +208,10 @@ test("Successfully uploading a database to github.com", async (t) => {
|
||||
|
||||
await mockHttpRequests(201);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
fs.writeFileSync(outputFilePath, "");
|
||||
},
|
||||
});
|
||||
|
||||
const loggedMessages = [] as LoggedMessage[];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
getTestConfig(tmpDir),
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages),
|
||||
@@ -233,15 +237,10 @@ test("Successfully uploading a database to GHEC-DR", async (t) => {
|
||||
|
||||
const databaseUploadSpy = await mockHttpRequests(201);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
fs.writeFileSync(outputFilePath, "");
|
||||
},
|
||||
});
|
||||
|
||||
const loggedMessages = [] as LoggedMessage[];
|
||||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getCodeQL(),
|
||||
getTestConfig(tmpDir),
|
||||
{
|
||||
auth: "1234",
|
||||
|
||||
Reference in New Issue
Block a user