mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-05 23:09:37 +00:00
Add SBT in cache managers. (#302)
This commit is contained in:
@ -118,6 +118,23 @@ describe('dependency cache', () => {
|
||||
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 [**/*.sbt,**/project/build.properties,**/project/**.{scala,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', () => {
|
||||
let spyCacheSave: jest.SpyInstance<
|
||||
@ -194,6 +211,30 @@ describe('dependency cache', () => {
|
||||
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:.*/));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user