mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-07-20 23:57:11 -04:00
[PR #230] [MERGED] test: add unit tests for key server/models validation types #251
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/vxcontrol/pentagi/pull/230
Author: @mason5052
Created: 3/31/2026
Status: ✅ Merged
Merged: 4/7/2026
Merged by: @asdek
Base:
main← Head:test/server-models-validation📝 Commits (3)
5d4638etest: add unit tests for server/models validation functions62dbefdtest: fill coverage gaps in server/models validation tests1b2681ctest: shadow loop variable to prevent parallel subtest capture📊 Changes
7 files changed (+2261 additions, -0 deletions)
View changed files
➕
backend/pkg/server/models/api_tokens_test.go(+255 -0)➕
backend/pkg/server/models/assistants_test.go(+211 -0)➕
backend/pkg/server/models/flows_test.go(+711 -0)➕
backend/pkg/server/models/init_test.go(+250 -0)➕
backend/pkg/server/models/prompts_test.go(+111 -0)➕
backend/pkg/server/models/providers_test.go(+161 -0)➕
backend/pkg/server/models/users_test.go(+562 -0)📄 Description
What
Add unit tests for validation logic across key
server/modelstypes: users, providers, API tokens, flows, tasks, containers, assistants, prompts, roles, and custom validators.This does not cover every exported validator in the package (log models, analytics, msgchains, screenshots, and vecstore models are not included).
Why
These model types contain security-sensitive validation functions (password strength, OAuth scope, JWT claims, API token TTL bounds) and core domain validation (enum status types, struct field requirements, nested model validation). None had test coverage.
Test Files
users_test.goproviders_test.goapi_tokens_test.goflows_test.goinit_test.goassistants_test.goprompts_test.goTest Approach
t.Parallel()for fast executionvalidateandscanFromJSONVerification
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.