mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 21:57:54 +00:00
f08316dc57
This paves the way for running multiple applications and storing information related to the application against the application itself. A couple of hacks have been added to v1 and v2 endpoints to maintain compatability but these should eventually be removed with the addition of a v3 api. Change-type: minor Signed-off-by: Cameron Diver <cameron@balena.io>
37 lines
1.1 KiB
TypeScript
37 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);
|
|
});
|
|
});
|