feat(test): add end-to-end test coverage for container lifecycle, auth, buckets, objects, policies, credentials, status, and S3 compatibility
This commit is contained in:
56
test/test.container-lifecycle.test.ts
Normal file
56
test/test.container-lifecycle.test.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { assertEquals, assertExists } from 'jsr:@std/assert';
|
||||
import { afterAll, beforeAll, describe, it } from 'jsr:@std/testing/bdd';
|
||||
import { createTestContainer, getTestPorts } from './helpers/server.helper.ts';
|
||||
import { ObjectStorageContainer } from '../ts/index.ts';
|
||||
import { defaultConfig } from '../ts/types.ts';
|
||||
|
||||
const PORT_INDEX = 0;
|
||||
const ports = getTestPorts(PORT_INDEX);
|
||||
|
||||
describe('ObjectStorageContainer lifecycle', { sanitizeResources: false, sanitizeOps: false }, () => {
|
||||
let container: ObjectStorageContainer;
|
||||
|
||||
it('should create container with default config values', () => {
|
||||
const c = new ObjectStorageContainer();
|
||||
assertEquals(c.config.objstPort, defaultConfig.objstPort);
|
||||
assertEquals(c.config.uiPort, defaultConfig.uiPort);
|
||||
assertEquals(c.config.region, defaultConfig.region);
|
||||
assertEquals(c.config.adminPassword, defaultConfig.adminPassword);
|
||||
});
|
||||
|
||||
it('should create container with custom config overrides', () => {
|
||||
container = createTestContainer(PORT_INDEX);
|
||||
assertEquals(container.config.objstPort, ports.objstPort);
|
||||
assertEquals(container.config.uiPort, ports.uiPort);
|
||||
assertEquals(container.config.adminPassword, 'testpassword');
|
||||
assertEquals(container.config.accessCredentials[0].accessKeyId, 'testkey');
|
||||
});
|
||||
|
||||
it('should start successfully', async () => {
|
||||
await container.start();
|
||||
assertEquals(container.startedAt > 0, true);
|
||||
});
|
||||
|
||||
it('should have s3Client initialized after start', () => {
|
||||
assertExists(container.s3Client);
|
||||
});
|
||||
|
||||
it('should have smartstorageInstance initialized after start', () => {
|
||||
assertExists(container.smartstorageInstance);
|
||||
});
|
||||
|
||||
it('should have policyManager with empty policies', () => {
|
||||
assertExists(container.policyManager);
|
||||
const policies = container.policyManager.listPolicies();
|
||||
assertEquals(policies.length, 0);
|
||||
});
|
||||
|
||||
it('should have opsServer started', () => {
|
||||
assertExists(container.opsServer);
|
||||
assertExists(container.opsServer.server);
|
||||
});
|
||||
|
||||
it('should stop cleanly', async () => {
|
||||
await container.stop();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user