Reset cache for all tests

This commit is contained in:
Jacob Wallraff
2023-03-06 11:52:21 -08:00
parent 6aaeefb9c2
commit 70c122b0e4
11 changed files with 57 additions and 2 deletions
@@ -17,7 +17,7 @@ export async function createWorkflowContext(
if (!parsed.value) {
throw new Error("Failed to parse workflow");
}
const template = await convertWorkflowTemplate("test.yaml", parsed.context, parsed.value);
const template = await convertWorkflowTemplate(parsed.context, parsed.value);
const context: WorkflowContext = {uri: "test.yaml", template};
if (job) {
+6
View File
@@ -5,9 +5,15 @@ import {registerLogger} from "./log";
import {getPositionFromCursor} from "./test-utils/cursor-position";
import {TestLogger} from "./test-utils/logger";
import {ValueProviderConfig, ValueProviderKind} from "./value-providers/config";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
registerLogger(new TestLogger());
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("completion", () => {
it("runs-on", async () => {
const input = "on: push\njobs:\n build:\n runs-on: |";
@@ -1,5 +1,11 @@
import {documentLinks} from "./document-links";
import {createDocument} from "./test-utils/document";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("documentLinks", () => {
it("no links without actions", async () => {
@@ -5,6 +5,7 @@ import {hover} from "./hover";
import {registerLogger} from "./log";
import {getPositionFromCursor} from "./test-utils/cursor-position";
import {TestLogger} from "./test-utils/logger";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
const contextProviderConfig: ContextProviderConfig = {
getContext: async (context: string) => {
@@ -34,6 +35,11 @@ const contextProviderConfig: ContextProviderConfig = {
registerLogger(new TestLogger());
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("hover.expressions", () => {
it("context access", async () => {
const input = `on: push
@@ -1,6 +1,12 @@
import {hover} from "./hover";
import {testHoverConfig} from "./hover.test";
import {getPositionFromCursor} from "./test-utils/cursor-position";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("hover.reusable-workflow", () => {
it("hover on job input with description", async () => {
+6
View File
@@ -3,6 +3,7 @@ import {StringToken} from "@github/actions-workflow-parser/templates/tokens/stri
import {DescriptionProvider, hover, HoverConfig} from "./hover";
import {getPositionFromCursor} from "./test-utils/cursor-position";
import {testFileProvider} from "./test-utils/test-file-provider";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
export function testHoverConfig(tokenValue: string, tokenKey: string, description?: string) {
return {
@@ -22,6 +23,11 @@ export function testHoverConfig(tokenValue: string, tokenKey: string, descriptio
} satisfies HoverConfig;
}
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("hover", () => {
it("on a key", async () => {
const input = `o|n: push
@@ -18,7 +18,7 @@ export async function testGetWorkflowContext(input: string): Promise<WorkflowCon
let template: WorkflowTemplate | undefined;
if (result.value) {
template = await convertWorkflowTemplate("wf.yaml", result.context, result.value, testFileProvider, {
template = await convertWorkflowTemplate(result.context, result.value, testFileProvider, {
fetchReusableWorkflowDepth: 1
});
}
@@ -5,9 +5,15 @@ import {createDocument} from "./test-utils/document";
import {TestLogger} from "./test-utils/logger";
import {validate, ValidationConfig} from "./validate";
import {ValueProviderKind} from "./value-providers/config";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
registerLogger(new TestLogger());
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
const validationConfig: ValidationConfig = {
fetchActionMetadata: async (ref: ActionReference) => {
let metadata: ActionMetadata | undefined = undefined;
@@ -5,9 +5,16 @@ import {registerLogger} from "./log";
import {createDocument} from "./test-utils/document";
import {TestLogger} from "./test-utils/logger";
import {validate, ValidationConfig} from "./validate";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
registerLogger(new TestLogger());
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("expression validation", () => {
it("access invalid context field", async () => {
const result = await validate(
+6
View File
@@ -2,6 +2,12 @@ import {Diagnostic, DiagnosticSeverity} from "vscode-languageserver-types";
import {createDocument} from "./test-utils/document";
import {validate} from "./validate";
import {defaultValueProviders} from "./value-providers/default";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("validation", () => {
it("valid workflow", async () => {
@@ -1,7 +1,13 @@
import {createDocument} from "./test-utils/document";
import {testFileProvider} from "./test-utils/test-file-provider";
import {clearParsedCache, clearWorkflowTemplateCache} from "./utils/workflow-cache";
import {validate} from "./validate";
beforeEach(() => {
clearWorkflowTemplateCache();
clearParsedCache();
});
describe("workflow references validation", () => {
it("invalid workflow reference", async () => {
const input = `