Add unit tests for models and services
- Implemented unit tests for the Package model, covering methods such as generateId, findById, findByName, and version management. - Created unit tests for the Repository model, including repository creation, name validation, and retrieval methods. - Added tests for the Session model, focusing on session creation, validation, and invalidation. - Developed unit tests for the User model, ensuring user creation, password hashing, and retrieval methods function correctly. - Implemented AuthService tests, validating login, token refresh, and session management. - Added TokenService tests, covering token creation, validation, and revocation processes.
This commit is contained in:
60
test/test.config.ts
Normal file
60
test/test.config.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Test configuration for Stack.Gallery Registry tests
|
||||
*/
|
||||
|
||||
export const testConfig = {
|
||||
mongodb: {
|
||||
url: 'mongodb://testadmin:testpass@localhost:27117/test-registry?authSource=admin',
|
||||
name: 'test-registry',
|
||||
},
|
||||
s3: {
|
||||
endpoint: 'http://localhost:9100',
|
||||
accessKey: 'testadmin',
|
||||
secretKey: 'testpassword',
|
||||
bucket: 'test-registry',
|
||||
region: 'us-east-1',
|
||||
},
|
||||
jwt: {
|
||||
secret: 'test-jwt-secret-for-testing-only',
|
||||
refreshSecret: 'test-refresh-secret-for-testing-only',
|
||||
},
|
||||
registry: {
|
||||
url: 'http://localhost:3000',
|
||||
port: 3000,
|
||||
},
|
||||
testUser: {
|
||||
email: 'test@stack.gallery',
|
||||
password: 'TestPassword123!',
|
||||
username: 'testuser',
|
||||
},
|
||||
adminUser: {
|
||||
email: 'admin@stack.gallery',
|
||||
password: 'admin',
|
||||
username: 'admin',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Get test config with environment variable overrides
|
||||
*/
|
||||
export function getTestConfig() {
|
||||
return {
|
||||
...testConfig,
|
||||
mongodb: {
|
||||
...testConfig.mongodb,
|
||||
url: Deno.env.get('TEST_MONGODB_URL') || testConfig.mongodb.url,
|
||||
name: Deno.env.get('TEST_MONGODB_NAME') || testConfig.mongodb.name,
|
||||
},
|
||||
s3: {
|
||||
...testConfig.s3,
|
||||
endpoint: Deno.env.get('TEST_S3_ENDPOINT') || testConfig.s3.endpoint,
|
||||
accessKey: Deno.env.get('TEST_S3_ACCESS_KEY') || testConfig.s3.accessKey,
|
||||
secretKey: Deno.env.get('TEST_S3_SECRET_KEY') || testConfig.s3.secretKey,
|
||||
bucket: Deno.env.get('TEST_S3_BUCKET') || testConfig.s3.bucket,
|
||||
},
|
||||
registry: {
|
||||
...testConfig.registry,
|
||||
url: Deno.env.get('TEST_REGISTRY_URL') || testConfig.registry.url,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user