@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.
@@ -14,51 +14,33 @@ import {
14
14
  it,
15
15
  mock,
16
16
  } from 'bun:test';
17
- import {
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 redisContainer: StartedTestContainer;
32
- let redisUrl: string;
28
+ let redis: TestContainer;
33
29
  let storage: RedisWsStorage;
34
30
 
35
31
  beforeAll(async () => {
36
- // Start Redis container
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: redisUrl,
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
- if (redisContainer) {
60
- await redisContainer.stop();
61
- }
43
+ await redis.stop();
62
44
  });
63
45
 
64
46
  beforeEach(async () => {