mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 10:26:46 +00:00
Add sbt cache tests.
This commit is contained in:
parent
754319f3bb
commit
a618b3f170
2 changed files with 42 additions and 0 deletions
|
@ -118,6 +118,23 @@ describe('dependency cache', () => {
|
||||||
expect(spyInfo).toBeCalledWith('gradle cache is not found');
|
expect(spyInfo).toBeCalledWith('gradle cache is not found');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('for sbt', () => {
|
||||||
|
it('throws error if no build.sbt found', async () => {
|
||||||
|
await expect(restore('sbt')).rejects.toThrowError(
|
||||||
|
`No file in ${projectRoot(
|
||||||
|
workspace
|
||||||
|
)} matched to [**/build.sbt], make sure you have checked out the target repository`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('downloads cache', async () => {
|
||||||
|
createFile(join(workspace, 'build.sbt'));
|
||||||
|
|
||||||
|
await restore('sbt');
|
||||||
|
expect(spyCacheRestore).toBeCalled();
|
||||||
|
expect(spyWarning).not.toBeCalled();
|
||||||
|
expect(spyInfo).toBeCalledWith('sbt cache is not found');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('save', () => {
|
describe('save', () => {
|
||||||
let spyCacheSave: jest.SpyInstance<
|
let spyCacheSave: jest.SpyInstance<
|
||||||
|
@ -194,6 +211,30 @@ describe('dependency cache', () => {
|
||||||
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
|
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('for sbt', () => {
|
||||||
|
it('uploads cache even if no build.sbt found', async () => {
|
||||||
|
createStateForMissingBuildFile();
|
||||||
|
await save('sbt');
|
||||||
|
expect(spyCacheSave).toBeCalled();
|
||||||
|
expect(spyWarning).not.toBeCalled();
|
||||||
|
});
|
||||||
|
it('does not upload cache if no restore run before', async () => {
|
||||||
|
createFile(join(workspace, 'build.sbt'));
|
||||||
|
|
||||||
|
await save('sbt');
|
||||||
|
expect(spyCacheSave).not.toBeCalled();
|
||||||
|
expect(spyWarning).toBeCalledWith('Error retrieving key from state.');
|
||||||
|
});
|
||||||
|
it('uploads cache', async () => {
|
||||||
|
createFile(join(workspace, 'build.sbt'));
|
||||||
|
createStateForSuccessfulRestore();
|
||||||
|
|
||||||
|
await save('sbt');
|
||||||
|
expect(spyCacheSave).toBeCalled();
|
||||||
|
expect(spyWarning).not.toBeCalled();
|
||||||
|
expect(spyInfo).toBeCalledWith(expect.stringMatching(/^Cache saved with the key:.*/));
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
1
__tests__/cache/sbt/build.sbt
vendored
Normal file
1
__tests__/cache/sbt/build.sbt
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ThisBuild / scalaVersion := "3.1.1"
|
Loading…
Add table
Add a link
Reference in a new issue