mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-11 07:23:09 +00:00
e1e35eb83b
We are refactoring the supervisor test suite into unit tests (for algorithms an domain model tests) and integration tests (for interaction with out-of-process dependencies). This means the current test suite needs to be classified into these two categories, and fixed whenever possible. This commit moves the test suite under the `test/legacy` folder, this folder should be progressively migrated and eventually removed. Subsequent commits will begin to split these files into unit and integration whenever possible. Depends-on: #1996 Change-type: patch
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { expect } from 'chai';
|
|
|
|
import * as commitStore from '~/src/compose/commit';
|
|
import * as db from '~/src/db';
|
|
|
|
describe('compose/commit', () => {
|
|
before(async () => await db.initialized);
|
|
|
|
describe('Fetching commits', () => {
|
|
beforeEach(async () => {
|
|
// Clear the commit values in the db
|
|
await db.models('currentCommit').del();
|
|
});
|
|
|
|
it('should fetch a commit for an appId', async () => {
|
|
const commit = 'abcdef';
|
|
await commitStore.upsertCommitForApp(1, commit);
|
|
|
|
expect(await commitStore.getCommitForApp(1)).to.equal(commit);
|
|
});
|
|
|
|
it('should fetch the correct commit value when there is multiple commits', async () => {
|
|
const commit = 'abcdef';
|
|
await commitStore.upsertCommitForApp(1, '123456');
|
|
await commitStore.upsertCommitForApp(2, commit);
|
|
|
|
expect(await commitStore.getCommitForApp(2)).to.equal(commit);
|
|
});
|
|
});
|
|
|
|
it('should correctly insert a commit when a commit for the same app already exists', async () => {
|
|
const commit = 'abcdef';
|
|
await commitStore.upsertCommitForApp(1, '123456');
|
|
await commitStore.upsertCommitForApp(1, commit);
|
|
expect(await commitStore.getCommitForApp(1)).to.equal(commit);
|
|
});
|
|
});
|