mirror of
https://github.com/mileswolfallen2/miles-web.git
synced 2026-12-06 08:33:55 +00:00
Add comprehensive test suite for application functionality
- Implement tests for HTTP API endpoints, ensuring correct responses and security headers. - Create configuration tests to validate loading of defaults and environment overrides. - Add tests for FEDL service to verify data handling and snapshot functionality. - Introduce GitHub service tests to check API data normalization and caching behavior. - Develop monitor service tests for network checks and uptime calculations. - Implement persistence tests to ensure database migrations are idempotent and data persists across restarts. - Add vault service tests for session management and brute-force protection mechanisms. - Include helper functions for test context creation and JSON response handling.
This commit is contained in:
1 parent
84b7a7e302
commit
c250653961
55 files changed
+8174
-226
No files matched your search
@@ -0,0 +1,89 @@
|
||||
export function seedConfig(db, config, { now = new Date() } = {}) {
|
||||
const ts = now.toISOString();
|
||||
|
||||
const upsertServer = db.prepare(`
|
||||
INSERT INTO servers (id, name, ip, display_order, enabled, created_at, updated_at)
|
||||
VALUES (@id, @name, @ip, @order, @enabled, @ts, @ts)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
name = excluded.name,
|
||||
ip = excluded.ip,
|
||||
display_order = excluded.display_order,
|
||||
enabled = excluded.enabled,
|
||||
updated_at = excluded.updated_at
|
||||
`);
|
||||
|
||||
const upsertService = db.prepare(`
|
||||
INSERT INTO services (id, name, url, display_order, enabled, created_at, updated_at)
|
||||
VALUES (@id, @name, @url, @order, @enabled, @ts, @ts)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
name = excluded.name,
|
||||
url = excluded.url,
|
||||
display_order = excluded.display_order,
|
||||
enabled = excluded.enabled,
|
||||
updated_at = excluded.updated_at
|
||||
`);
|
||||
|
||||
const upsertProject = db.prepare(`
|
||||
INSERT INTO projects (
|
||||
id, name, description, github_owner, github_repo, website_url,
|
||||
api_type, api_base, display_order, visible, featured, updated_at
|
||||
)
|
||||
VALUES (
|
||||
@id, @name, @description, @githubOwner, @githubRepo, @website,
|
||||
@apiType, @apiBase, @order, @visible, @featured, @ts
|
||||
)
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
name = excluded.name,
|
||||
description = excluded.description,
|
||||
github_owner = excluded.github_owner,
|
||||
github_repo = excluded.github_repo,
|
||||
website_url = excluded.website_url,
|
||||
api_type = excluded.api_type,
|
||||
api_base = excluded.api_base,
|
||||
display_order = excluded.display_order,
|
||||
visible = excluded.visible,
|
||||
featured = excluded.featured,
|
||||
updated_at = excluded.updated_at
|
||||
`);
|
||||
|
||||
db.transaction(() => {
|
||||
for (const server of config.servers) {
|
||||
upsertServer.run({
|
||||
id: server.id,
|
||||
name: server.name,
|
||||
ip: server.ip,
|
||||
order: server.order,
|
||||
enabled: server.enabled ? 1 : 0,
|
||||
ts
|
||||
});
|
||||
}
|
||||
|
||||
for (const service of config.services) {
|
||||
upsertService.run({
|
||||
id: service.id,
|
||||
name: service.name,
|
||||
url: service.url,
|
||||
order: service.order,
|
||||
enabled: service.enabled ? 1 : 0,
|
||||
ts
|
||||
});
|
||||
}
|
||||
|
||||
for (const project of config.projects) {
|
||||
upsertProject.run({
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
description: project.description,
|
||||
githubOwner: project.github?.owner || null,
|
||||
githubRepo: project.github?.repo || null,
|
||||
website: project.website || null,
|
||||
apiType: project.api?.type || null,
|
||||
apiBase: project.api?.base || null,
|
||||
order: project.order,
|
||||
visible: project.visible ? 1 : 0,
|
||||
featured: project.featured ? 1 : 0,
|
||||
ts
|
||||
});
|
||||
}
|
||||
})();
|
||||
}
|
||||
Reference in new issue
Block a user