feat(repos): resources (+ deps + creds) and source_docs
This commit is contained in:
30
tests/repos/resources.test.js
Normal file
30
tests/repos/resources.test.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { resetDb } from '../helpers/db.js';
|
||||
import { migrateUp } from '../../lib/db/migrate.js';
|
||||
import * as spaces from '../../lib/db/repos/spaces.js';
|
||||
import * as resources from '../../lib/db/repos/resources.js';
|
||||
|
||||
const owner = { kind: 'user', id: null };
|
||||
beforeEach(async () => { await resetDb(); await migrateUp(); });
|
||||
|
||||
describe('resources repo', () => {
|
||||
it('creates a resource', async () => {
|
||||
const s = await spaces.create({ slug: 'h', name: 'H' }, owner);
|
||||
const r = await resources.create({
|
||||
space_id: s.id, slug: 'kk', name: 'Karakeep',
|
||||
runtime_type: 'docker', host: '192.168.1.230', url: 'https://karakeep.hynesy.com'
|
||||
}, owner);
|
||||
expect(r.status).toBe('unknown');
|
||||
});
|
||||
|
||||
it('addDependency creates a link, prevents self-dep', async () => {
|
||||
const s = await spaces.create({ slug: 'h', name: 'H' }, owner);
|
||||
const a = await resources.create({ space_id: s.id, slug: 'a', name: 'A', runtime_type: 'lxc' }, owner);
|
||||
const b = await resources.create({ space_id: s.id, slug: 'b', name: 'B', runtime_type: 'lxc' }, owner);
|
||||
await resources.addDependency(a.id, b.id, 'data');
|
||||
const deps = await resources.listDependencies(a.id);
|
||||
expect(deps).toHaveLength(1);
|
||||
expect(deps[0].depends_on).toBe(b.id);
|
||||
await expect(resources.addDependency(a.id, a.id, 'self')).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user