GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — setup-java/__tests__/setup-java.module-loading.test.ts at main · NOUIY/setup-java Expand file tree/ Copy pathsetup-java.module-loading.test.tsMore file actions 121 lines (105 loc) · 3.56 KB / Copy pathsetup-java.module-loading.test.tsFile metadata and controls121 lines (105 loc) · 3.56 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 import {jest, describe, it, expect, beforeEach} from '@jest/globals'; jest.unstable_mockModule('@actions/core', () => ({ info: jest.fn(), warning: jest.fn(), debug: jest.fn(), error: jest.fn(), notice: jest.fn(), setFailed: jest.fn(), setOutput: jest.fn(), getInput: jest.fn(), getBooleanInput: jest.fn(), getMultilineInput: jest.fn(), addPath: jest.fn(), exportVariable: jest.fn(), saveState: jest.fn(), getState: jest.fn(), setSecret: jest.fn(), isDebug: jest.fn(() => false), startGroup: jest.fn(), endGroup: jest.fn(), group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()), toPlatformPath: jest.fn((value: string) => value), toWin32Path: jest.fn((value: string) => value), toPosixPath: jest.fn((value: string) => value) })); jest.unstable_mockModule('fs', () => ({ default: { ...jest.requireActual<typeof import('fs')>('fs'), readFileSync: jest.fn() } })); jest.unstable_mockModule('../src/util.js', () => ({ getBooleanInput: jest.fn(), getVersionFromFileContent: jest.fn(), isJdkCacheEnabled: jest.fn() })); jest.unstable_mockModule('../src/toolchains.js', () => ({ validateToolchainIds: jest.fn(), configureToolchains: jest.fn() })); jest.unstable_mockModule( '../src/distributions/distribution-factory.js', () => ({ getJavaDistribution: jest.fn() }) ); jest.unstable_mockModule('../src/auth.js', () => ({ configureAuthentication: jest.fn() })); jest.unstable_mockModule('../src/maven-args.js', () => ({ configureMavenArgs: jest.fn() })); jest.unstable_mockModule('../src/problem-matcher.js', () => ({ configureProblemMatcher: jest.fn() })); // These modules should never be imported when `cache` input is empty. jest.unstable_mockModule('../src/cache-feature.js', () => { throw new Error('cache-feature module should not be loaded'); }); jest.unstable_mockModule('../src/cache.js', () => { throw new Error('cache module should not be loaded'); }); const core = await import('@actions/core'); const util = await import('../src/util.js'); const toolchains = await import('../src/toolchains.js'); const factory = await import('../src/distributions/distribution-factory.js'); const {run} = await import('../src/setup-java.js'); describe('setup-java conditional module loading', () => { const inputs = new Map<string, string>(); const multilineInputs = new Map<string, string[]>(); const booleanInputs = new Map<string, boolean>(); beforeEach(() => { jest.resetAllMocks(); inputs.clear(); multilineInputs.clear(); booleanInputs.clear(); (core.getInput as jest.Mock).mockImplementation((name: unknown) => { return inputs.get(name as string) ?? ''; }); (core.getMultilineInput as jest.Mock).mockImplementation( (name: unknown) => { return multilineInputs.get(name as string) ?? []; } ); (util.getBooleanInput as jest.Mock).mockImplementation( (name: unknown, defaultValue: unknown) => { return booleanInputs.get(name as string) ?? defaultValue; } ); (util.isJdkCacheEnabled as jest.Mock).mockReturnValue(false); (toolchains.configureToolchains as jest.Mock).mockResolvedValue(undefined); }); it('does not import cache modules when cache input is not provided', async () => { inputs.set('distribution', 'temurin'); multilineInputs.set('java-version', ['21']); (factory.getJavaDistribution as jest.Mock).mockResolvedValue({ setupJava: jest.fn(async () => ({ version: '21.0.4+7', path: '/opt/java/21' })) }); await run(); expect(core.setFailed).not.toHaveBeenCalled(); }); }); |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |