Update tests to remove feature flag
This commit is contained in:
parent
1a686e7d76
commit
10249d1591
9 changed files with 17 additions and 35 deletions
|
|
@ -10,7 +10,7 @@ import * as apiClient from "./api-client";
|
|||
import { setCodeQL } from "./codeql";
|
||||
import { Config } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import { createFeatureFlags, FeatureFlag, FeatureFlags } from "./feature-flags";
|
||||
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import {
|
||||
|
|
@ -37,7 +37,6 @@ test.beforeEach(() => {
|
|||
|
||||
const uploadToUploadsDomainFlags = createFeatureFlags([
|
||||
FeatureFlag.DatabaseUploadsEnabled,
|
||||
FeatureFlag.UploadsDomainEnabled,
|
||||
]);
|
||||
|
||||
const testRepoName: RepositoryNwo = { owner: "github", repo: "example" };
|
||||
|
|
@ -65,18 +64,14 @@ function getTestConfig(tmpDir: string): Config {
|
|||
};
|
||||
}
|
||||
|
||||
async function mockHttpRequests(
|
||||
featureFlags: FeatureFlags,
|
||||
databaseUploadStatusCode: number
|
||||
) {
|
||||
async function mockHttpRequests(databaseUploadStatusCode: number) {
|
||||
// Passing an auth token is required, so we just use a dummy value
|
||||
const client = github.getOctokit("123");
|
||||
|
||||
const requestSpy = sinon.stub(client, "request");
|
||||
|
||||
const url = (await featureFlags.getValue(FeatureFlag.UploadsDomainEnabled))
|
||||
? "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name"
|
||||
: "PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language";
|
||||
const url =
|
||||
"POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name";
|
||||
const databaseUploadSpy = requestSpy.withArgs(url);
|
||||
if (databaseUploadStatusCode < 300) {
|
||||
databaseUploadSpy.resolves(undefined);
|
||||
|
|
@ -222,7 +217,7 @@ test("Abort database upload if feature flag is disabled", async (t) => {
|
|||
await uploadDatabases(
|
||||
testRepoName,
|
||||
getTestConfig(tmpDir),
|
||||
createFeatureFlags([FeatureFlag.UploadsDomainEnabled]),
|
||||
createFeatureFlags([]),
|
||||
testApiDetails,
|
||||
getRecordingLogger(loggedMessages)
|
||||
);
|
||||
|
|
@ -250,7 +245,7 @@ test("Don't crash if uploading a database fails", async (t) => {
|
|||
FeatureFlag.DatabaseUploadsEnabled,
|
||||
]);
|
||||
|
||||
await mockHttpRequests(featureFlags, 500);
|
||||
await mockHttpRequests(500);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
|
|
@ -287,7 +282,7 @@ test("Successfully uploading a database to api.github.com", async (t) => {
|
|||
.returns("true");
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
|
||||
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
||||
await mockHttpRequests(201);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
|
|
@ -322,7 +317,7 @@ test("Successfully uploading a database to uploads.github.com", async (t) => {
|
|||
.returns("true");
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
|
||||
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
||||
await mockHttpRequests(201);
|
||||
|
||||
setCodeQL({
|
||||
async databaseBundle(_: string, outputFilePath: string) {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ test("Feature flags are disabled if they're not returned in API response", async
|
|||
for (const featureFlag of [
|
||||
"database_uploads_enabled",
|
||||
"ml_powered_queries_enabled",
|
||||
"uploads_domain_enabled",
|
||||
]) {
|
||||
t.assert(
|
||||
loggedMessages.find(
|
||||
|
|
@ -125,7 +124,6 @@ test("Feature flags exception is propagated if the API request errors", async (t
|
|||
const FEATURE_FLAGS = [
|
||||
"database_uploads_enabled",
|
||||
"ml_powered_queries_enabled",
|
||||
"uploads_domain_enabled",
|
||||
];
|
||||
|
||||
for (const featureFlag of FEATURE_FLAGS) {
|
||||
|
|
@ -154,9 +152,6 @@ for (const featureFlag of FEATURE_FLAGS) {
|
|||
ml_powered_queries_enabled: await featureFlags.getValue(
|
||||
FeatureFlag.MlPoweredQueriesEnabled
|
||||
),
|
||||
uploads_domain_enabled: await featureFlags.getValue(
|
||||
FeatureFlag.UploadsDomainEnabled
|
||||
),
|
||||
};
|
||||
|
||||
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ export interface FeatureFlags {
|
|||
export enum FeatureFlag {
|
||||
DatabaseUploadsEnabled = "database_uploads_enabled",
|
||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||
UploadsDomainEnabled = "uploads_domain_enabled",
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue