@onebun/core 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -1
- package/src/application/application.test.ts +229 -1
- package/src/decorators/decorators.ts +8 -1
- package/src/decorators/metadata.ts +25 -0
- package/src/module/controller.test.ts +110 -126
- package/src/module/service.test.ts +78 -51
- package/src/queue/adapters/redis.adapter.test.ts +7 -25
- package/src/redis/shared-redis.test.ts +21 -39
- package/src/testing/containers.test.ts +35 -0
- package/src/testing/containers.ts +89 -0
- package/src/testing/docs-examples.test.ts +280 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/service-helpers.test.ts +166 -0
- package/src/testing/service-helpers.ts +69 -0
- package/src/testing/testing-module.test.ts +80 -0
- package/src/testing/testing-module.ts +47 -2
- package/src/websocket/ws-storage-redis.test.ts +6 -24
|
@@ -14,51 +14,33 @@ import {
|
|
|
14
14
|
it,
|
|
15
15
|
mock,
|
|
16
16
|
} from 'bun:test';
|
|
17
|
-
|
|
18
|
-
GenericContainer,
|
|
19
|
-
type StartedTestContainer,
|
|
20
|
-
Wait,
|
|
21
|
-
} from 'testcontainers';
|
|
17
|
+
|
|
22
18
|
|
|
23
19
|
import type { WsClientData, WsRoom } from './ws.types';
|
|
24
20
|
|
|
25
21
|
import { SharedRedisProvider } from '../redis/shared-redis';
|
|
22
|
+
import { createRedisContainer, type TestContainer } from '../testing/containers';
|
|
26
23
|
|
|
27
24
|
import { WsStorageEvent, type WsStorageEventPayload } from './ws-storage';
|
|
28
25
|
import { RedisWsStorage, createRedisWsStorage } from './ws-storage-redis';
|
|
29
26
|
|
|
30
27
|
describe('RedisWsStorage', () => {
|
|
31
|
-
let
|
|
32
|
-
let redisUrl: string;
|
|
28
|
+
let redis: TestContainer;
|
|
33
29
|
let storage: RedisWsStorage;
|
|
34
30
|
|
|
35
31
|
beforeAll(async () => {
|
|
36
|
-
|
|
37
|
-
redisContainer = await new GenericContainer('redis:7-alpine')
|
|
38
|
-
.withExposedPorts(6379)
|
|
39
|
-
.withWaitStrategy(Wait.forLogMessage(/.*Ready to accept connections.*/))
|
|
40
|
-
.withStartupTimeout(30000)
|
|
41
|
-
.withLogConsumer(() => {
|
|
42
|
-
// Suppress container logs
|
|
43
|
-
})
|
|
44
|
-
.start();
|
|
45
|
-
|
|
46
|
-
const host = redisContainer.getHost();
|
|
47
|
-
const port = redisContainer.getMappedPort(6379);
|
|
48
|
-
redisUrl = `redis://${host}:${port}`;
|
|
32
|
+
redis = await createRedisContainer();
|
|
49
33
|
|
|
50
34
|
// Configure shared Redis
|
|
51
35
|
SharedRedisProvider.configure({
|
|
52
|
-
url:
|
|
36
|
+
url: redis.url,
|
|
53
37
|
keyPrefix: 'ws:test:',
|
|
54
38
|
});
|
|
55
39
|
});
|
|
56
40
|
|
|
57
41
|
afterAll(async () => {
|
|
58
42
|
await SharedRedisProvider.reset();
|
|
59
|
-
|
|
60
|
-
await redisContainer.stop();
|
|
61
|
-
}
|
|
43
|
+
await redis.stop();
|
|
62
44
|
});
|
|
63
45
|
|
|
64
46
|
beforeEach(async () => {
|