Skip to content

Commit

Permalink
tests: ensuring an error is thrown when no containers have been found
Browse files Browse the repository at this point in the history
  • Loading branch information
axel7083 committed Jan 24, 2024
1 parent c98fa5c commit 7117692
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/backend/src/managers/applicationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,46 @@ describe('pullApplication', () => {
expect(cloneRepositoryMock).not.toHaveBeenCalled();
expect(downloadModelMainSpy).not.toHaveBeenCalled();
});

test('pullApplication should mark the loading config as error if not container are found', async () => {
mockForPullApplication({
recipeFolderExists: true,
});
getLocalModelsSpy.mockReturnValue([
{
id: 'model1',
file: 'model1.file',
},
]);

const recipe: Recipe = {
id: 'recipe1',
name: 'Recipe 1',
categories: [],
description: '',
readme: '',
repository: 'repo',
};
const model: ModelInfo = {
id: 'model1',
description: '',
hw: '',
license: '',
name: 'Model 1',
popularity: 1,
registry: '',
url: '',
};

mocks.parseYamlMock.mockReturnValue({
application: {
containers: [],
},
});

await expect(manager.pullApplication(recipe, model)).rejects.toThrowError('No containers available.');

expect(cloneRepositoryMock).not.toHaveBeenCalled();
expect(downloadModelMainSpy).not.toHaveBeenCalled();
});
});
1 change: 1 addition & 0 deletions packages/backend/src/managers/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class ApplicationManager {
// Mark as failure.
loadingConfiguration.state = 'error';
taskUtil.setTask(loadingConfiguration);
throw new Error('No containers available.');
}

const localModels = this.modelsManager.getLocalModels();
Expand Down

0 comments on commit 7117692

Please sign in to comment.