mirror of
https://code.forgejo.org/actions/cache.git
synced 2024-11-27 14:39:16 +01:00
Fix test
This commit is contained in:
parent
67f61c6e6b
commit
2850cd8f45
2 changed files with 23 additions and 30 deletions
|
@ -32,6 +32,8 @@ beforeAll(() => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env[Events.Key] = Events.Push;
|
process.env[Events.Key] = Events.Push;
|
||||||
process.env[RefKey] = "refs/heads/feature-branch";
|
process.env[RefKey] = "refs/heads/feature-branch";
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -54,15 +56,11 @@ test("restore with invalid event outputs warning", async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("restore on GHES should no-op", async () => {
|
test("restore on GHES should no-op", async () => {
|
||||||
try {
|
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
|
||||||
process.env["GITHUB_SERVER_URL"] = "http://example.com";
|
|
||||||
|
|
||||||
const infoMock = jest.spyOn(core, "info");
|
const infoMock = jest.spyOn(core, "info");
|
||||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||||
const setCacheHitOutputMock = jest.spyOn(
|
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
|
||||||
actionUtils,
|
|
||||||
"setCacheHitOutput"
|
|
||||||
);
|
|
||||||
|
|
||||||
await run();
|
await run();
|
||||||
|
|
||||||
|
@ -72,9 +70,6 @@ test("restore on GHES should no-op", async () => {
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
"Cache action is not supported on GHES"
|
"Cache action is not supported on GHES"
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = undefined;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("restore with no path should fail", async () => {
|
test("restore with no path should fail", async () => {
|
||||||
|
|
|
@ -44,6 +44,8 @@ beforeAll(() => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.env[Events.Key] = Events.Push;
|
process.env[Events.Key] = Events.Push;
|
||||||
process.env[RefKey] = "refs/heads/feature-branch";
|
process.env[RefKey] = "refs/heads/feature-branch";
|
||||||
|
|
||||||
|
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -92,8 +94,7 @@ test("save with no primary key in state outputs warning", async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save on GHES should no-op", async () => {
|
test("save on GHES should no-op", async () => {
|
||||||
try {
|
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
|
||||||
process.env["GITHUB_SERVER_URL"] = "http://example.com";
|
|
||||||
|
|
||||||
const infoMock = jest.spyOn(core, "info");
|
const infoMock = jest.spyOn(core, "info");
|
||||||
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
const saveCacheMock = jest.spyOn(cache, "saveCache");
|
||||||
|
@ -104,9 +105,6 @@ test("save on GHES should no-op", async () => {
|
||||||
expect(infoMock).toHaveBeenCalledWith(
|
expect(infoMock).toHaveBeenCalledWith(
|
||||||
"Cache action is not supported on GHES"
|
"Cache action is not supported on GHES"
|
||||||
);
|
);
|
||||||
} finally {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = undefined;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("save with exact match returns early", async () => {
|
test("save with exact match returns early", async () => {
|
||||||
|
|
Loading…
Reference in a new issue