@docker-harpoon/core 0.1.5 → 0.2.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docker-harpoon/core",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Core Docker resource primitives and binding interface",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1,10 +0,0 @@
1
- /**
2
- * Bindings Integration Tests
3
- *
4
- * Dogfoods the binding system to verify:
5
- * - createEnvBinding helper
6
- * - Env var injection into containers
7
- * - Binding composition
8
- */
9
- export {};
10
- //# sourceMappingURL=bindings.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bindings.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/bindings.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,128 +0,0 @@
1
- /**
2
- * Bindings Integration Tests
3
- *
4
- * Dogfoods the binding system to verify:
5
- * - createEnvBinding helper
6
- * - Env var injection into containers
7
- * - Binding composition
8
- */
9
- import { describe, test, expect, afterEach, beforeAll, setDefaultTimeout } from 'bun:test';
10
- import { Container, database, createEnvBinding, destroyAll } from '../index';
11
- import { buildTestImage, TEST_IMAGE } from './test-setup';
12
- setDefaultTimeout(30_000);
13
- const waitUntil = (fn, timeout = 5000) => {
14
- return new Promise((resolve) => {
15
- const interval = setInterval(() => {
16
- if (fn()) {
17
- clearInterval(interval);
18
- resolve(true);
19
- }
20
- }, 100);
21
- });
22
- };
23
- describe('Bindings', () => {
24
- beforeAll(async () => {
25
- await buildTestImage();
26
- });
27
- afterEach(async () => {
28
- await destroyAll();
29
- });
30
- test('createEnvBinding creates a simple env binding', () => {
31
- const binding = createEnvBinding('config', {
32
- NODE_ENV: 'test',
33
- LOG_LEVEL: 'debug',
34
- });
35
- expect(binding.type).toBe('config');
36
- expect(binding.getEnv()).toEqual({
37
- NODE_ENV: 'test',
38
- LOG_LEVEL: 'debug',
39
- });
40
- });
41
- test('container receives env vars from bindings', async () => {
42
- const configBinding = createEnvBinding('config', {
43
- APP_NAME: 'test-app',
44
- APP_VERSION: '1.0.0',
45
- });
46
- const container = await Container('test-binding-env', {
47
- image: TEST_IMAGE,
48
- cmd: ['sleep', '30'],
49
- bindings: {
50
- config: configBinding,
51
- },
52
- });
53
- await waitUntil(() => !!container.getIp('test-binding-env'), 5000);
54
- const result = await container.exec([
55
- 'sh',
56
- '-c',
57
- 'echo "$APP_NAME:$APP_VERSION"',
58
- ]);
59
- expect(result.stdout.trim()).toBe('test-app:1.0.0');
60
- await container.destroy();
61
- });
62
- test('multiple bindings merge env vars', async () => {
63
- const binding1 = createEnvBinding('env1', {
64
- VAR_A: 'a',
65
- VAR_B: 'b',
66
- });
67
- const binding2 = createEnvBinding('env2', {
68
- VAR_C: 'c',
69
- VAR_D: 'd',
70
- });
71
- const container = await Container('test-multi-binding', {
72
- image: TEST_IMAGE,
73
- cmd: ['sleep', '30'],
74
- bindings: {
75
- first: binding1,
76
- second: binding2,
77
- },
78
- });
79
- await waitUntil(() => !!container.getIp('test-multi-binding'), 5000);
80
- const result = await container.exec([
81
- 'sh',
82
- '-c',
83
- 'echo "$VAR_A$VAR_B$VAR_C$VAR_D"',
84
- ]);
85
- expect(result.stdout.trim()).toBe('abcd');
86
- await container.destroy();
87
- });
88
- test('explicit env takes precedence over bindings', async () => {
89
- const binding = createEnvBinding('config', {
90
- MY_VAR: 'from-binding',
91
- });
92
- const container = await Container('test-env-precedence', {
93
- image: TEST_IMAGE,
94
- cmd: ['sleep', '30'],
95
- bindings: {
96
- config: binding,
97
- },
98
- env: {
99
- MY_VAR: 'from-explicit',
100
- },
101
- });
102
- await waitUntil(() => !!container.getIp('test-env-precedence'), 5000);
103
- const result = await container.exec(['sh', '-c', 'echo "$MY_VAR"']);
104
- expect(result.stdout.trim()).toBe('from-explicit');
105
- await container.destroy();
106
- });
107
- test('database can be used as binding resource', async () => {
108
- const db = await database('test-db-binding', {
109
- image: 'redis:7-alpine',
110
- hostPort: 16390,
111
- });
112
- const dbBinding = createEnvBinding('database', {
113
- REDIS_URL: db.connectionString,
114
- });
115
- const container = await Container('test-db-consumer', {
116
- image: TEST_IMAGE,
117
- cmd: ['sleep', '30'],
118
- bindings: {
119
- db: dbBinding,
120
- },
121
- });
122
- await waitUntil(() => !!container.getIp('test-db-consumer'), 5000);
123
- const result = await container.exec(['sh', '-c', 'echo "$REDIS_URL"']);
124
- expect(result.stdout.trim()).toBe('redis://localhost:16390');
125
- await container.destroy();
126
- await db.destroy();
127
- });
128
- });
@@ -1,12 +0,0 @@
1
- /**
2
- * Container Resource Integration Tests
3
- *
4
- * Dogfoods the Container resource to verify:
5
- * - Creation with network binding
6
- * - waitForLog functionality
7
- * - exec command execution
8
- * - stats retrieval
9
- * - Lifecycle (stop, destroy)
10
- */
11
- export {};
12
- //# sourceMappingURL=container.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"container.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/container.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -1,136 +0,0 @@
1
- /**
2
- * Container Resource Integration Tests
3
- *
4
- * Dogfoods the Container resource to verify:
5
- * - Creation with network binding
6
- * - waitForLog functionality
7
- * - exec command execution
8
- * - stats retrieval
9
- * - Lifecycle (stop, destroy)
10
- */
11
- import { describe, test, expect, afterEach, beforeAll, setDefaultTimeout } from 'bun:test';
12
- import { Network, Container, destroyAll } from '../index';
13
- import { buildTestImage, TEST_IMAGE } from './test-setup';
14
- setDefaultTimeout(30_000);
15
- describe('Container', () => {
16
- beforeAll(async () => {
17
- await buildTestImage();
18
- });
19
- afterEach(async () => {
20
- await destroyAll();
21
- });
22
- test('creates a container with basic config', async () => {
23
- const container = await Container('test-container-basic', {
24
- image: TEST_IMAGE,
25
- cmd: ['sleep', '30'],
26
- });
27
- expect(container.id).toBeDefined();
28
- expect(container.name).toBe('test-container-basic');
29
- await container.destroy();
30
- });
31
- test('creates a container attached to a network', async () => {
32
- const network = await Network('test-container-net');
33
- const container = await Container('test-container-networked', {
34
- image: TEST_IMAGE,
35
- cmd: ['sleep', '30'],
36
- networks: [network],
37
- });
38
- expect(container.id).toBeDefined();
39
- const ip = await container.getIp('test-container-net');
40
- expect(ip).toBeDefined();
41
- await container.destroy();
42
- await network.destroy();
43
- });
44
- test('exec runs commands inside container', async () => {
45
- const container = await Container('test-container-exec', {
46
- image: TEST_IMAGE,
47
- cmd: ['sleep', '30'],
48
- });
49
- await new Promise((r) => setTimeout(r, 500));
50
- const result = await container.exec(['echo', 'hello world']);
51
- expect(result.exitCode).toBe(0);
52
- expect(result.stdout.trim()).toBe('hello world');
53
- expect(result.durationMs).toBeGreaterThan(0);
54
- await container.destroy();
55
- });
56
- test('stats returns container resource statistics', async () => {
57
- const container = await Container('test-container-stats', {
58
- image: TEST_IMAGE,
59
- cmd: ['sleep', '30'],
60
- });
61
- await new Promise((r) => setTimeout(r, 500));
62
- const stats = await container.stats();
63
- expect(stats.cpu).toBeDefined();
64
- expect(stats.cpu.cores).toBeGreaterThan(0);
65
- expect(stats.memory).toBeDefined();
66
- expect(stats.memory.limit).toBeGreaterThan(0);
67
- expect(stats.network).toBeDefined();
68
- expect(stats.containerId).toBe(container.id);
69
- await container.destroy();
70
- });
71
- test('waitForLog detects log patterns', async () => {
72
- const container = await Container('test-container-logs', {
73
- image: TEST_IMAGE,
74
- cmd: ['sh', '-c', 'echo "Server started successfully" && sleep 30'],
75
- });
76
- await container.waitForLog('Server started', 5000);
77
- expect(true).toBe(true);
78
- await container.destroy();
79
- });
80
- test('stop gracefully shuts down container', async () => {
81
- const container = await Container('test-container-stop', {
82
- image: TEST_IMAGE,
83
- cmd: ['sh', '-c', 'trap "exit 0" TERM; while true; do sleep 1; done'],
84
- });
85
- await new Promise((r) => setTimeout(r, 500));
86
- const metadata = await container.stop('SIGTERM', 10000);
87
- expect(metadata.signal).toBe('SIGTERM');
88
- expect(metadata.signalCount).toBeGreaterThan(0);
89
- expect(metadata.timeTakenMs).toBeGreaterThan(0);
90
- await container.destroy();
91
- });
92
- test('supports environment variables', async () => {
93
- const container = await Container('test-container-env', {
94
- image: TEST_IMAGE,
95
- cmd: ['sleep', '30'],
96
- env: {
97
- MY_VAR: 'hello',
98
- ANOTHER_VAR: 'world',
99
- },
100
- });
101
- await new Promise((r) => setTimeout(r, 500));
102
- const result = await container.exec([
103
- 'sh',
104
- '-c',
105
- 'echo $MY_VAR $ANOTHER_VAR',
106
- ]);
107
- expect(result.stdout.trim()).toBe('hello world');
108
- await container.destroy();
109
- });
110
- test('supports port mappings', async () => {
111
- const container = await Container('test-container-ports', {
112
- image: TEST_IMAGE,
113
- cmd: ['sleep', '30'],
114
- ports: [{ internal: 8080, external: 18080 }],
115
- });
116
- expect(container.id).toBeDefined();
117
- await container.destroy();
118
- });
119
- test('streamLogs terminates without follow option', async () => {
120
- const container = await Container('test-logs-terminate', {
121
- image: TEST_IMAGE,
122
- cmd: ['sh', '-c', 'echo "line1" && echo "line2" && echo "line3" && sleep 30'],
123
- });
124
- await container.waitForLog('line3', 5000);
125
- const lines = [];
126
- const logStream = await container.streamLogs({ tail: 3 });
127
- for await (const line of logStream) {
128
- lines.push(line.message);
129
- }
130
- // Loop should exit naturally
131
- expect(lines).toContain('line1');
132
- expect(lines).toContain('line2');
133
- expect(lines).toContain('line3');
134
- await container.destroy();
135
- });
136
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * Database Helper Integration Tests
3
- *
4
- * Dogfoods the database helper to verify:
5
- * - Connection string generation
6
- * - Port mapping
7
- * - Database-specific defaults
8
- */
9
- export {};
10
- //# sourceMappingURL=database.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"database.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/database.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,78 +0,0 @@
1
- /**
2
- * Database Helper Integration Tests
3
- *
4
- * Dogfoods the database helper to verify:
5
- * - Connection string generation
6
- * - Port mapping
7
- * - Database-specific defaults
8
- */
9
- import { describe, test, expect, afterEach, setDefaultTimeout } from 'bun:test';
10
- import { Network, database, destroyAll } from '../index';
11
- setDefaultTimeout(60_000);
12
- describe('database', () => {
13
- afterEach(async () => {
14
- await destroyAll();
15
- });
16
- test('creates a postgres database with connection string', async () => {
17
- const db = await database('test-postgres', {
18
- image: 'postgres:16-alpine',
19
- env: {
20
- POSTGRES_PASSWORD: 'testpass',
21
- POSTGRES_DB: 'testdb',
22
- },
23
- hostPort: 15432,
24
- });
25
- expect(db.id).toBeDefined();
26
- expect(db.name).toBe('test-postgres');
27
- expect(db.port).toBe(5432);
28
- expect(db.hostPort).toBe(15432);
29
- expect(db.connectionString).toBe('postgresql://postgres:testpass@localhost:15432/testdb');
30
- await db.destroy();
31
- });
32
- test('creates a redis database with connection string', async () => {
33
- const db = await database('test-redis', {
34
- image: 'redis:7-alpine',
35
- hostPort: 16379,
36
- });
37
- expect(db.port).toBe(6379);
38
- expect(db.hostPort).toBe(16379);
39
- expect(db.connectionString).toBe('redis://localhost:16379');
40
- await db.destroy();
41
- });
42
- test('creates a redis database with password', async () => {
43
- const db = await database('test-redis-auth', {
44
- image: 'redis:7-alpine',
45
- hostPort: 16380,
46
- env: {
47
- REDIS_PASSWORD: 'secret',
48
- },
49
- });
50
- expect(db.connectionString).toBe('redis://:secret@localhost:16380');
51
- await db.destroy();
52
- });
53
- test('attaches database to network', async () => {
54
- const network = await Network('test-db-net');
55
- const db = await database('test-db-networked', {
56
- image: 'redis:7-alpine',
57
- networks: [network],
58
- hostPort: 16381,
59
- });
60
- const ip = await db.getIp('test-db-net');
61
- expect(ip).toBeDefined();
62
- expect(ip).not.toBe('');
63
- await db.destroy();
64
- await network.destroy();
65
- });
66
- test('database inherits container methods', async () => {
67
- const db = await database('test-db-methods', {
68
- image: 'redis:7-alpine',
69
- hostPort: 16382,
70
- });
71
- await db.waitForLog('Ready to accept connections', 10000);
72
- const result = await db.exec(['redis-cli', 'PING']);
73
- expect(result.stdout.trim()).toBe('PONG');
74
- const stats = await db.stats();
75
- expect(stats.cpu).toBeDefined();
76
- await db.destroy();
77
- });
78
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=docker-infra.template.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docker-infra.template.d.ts","sourceRoot":"","sources":["../../src/__tests__/docker-infra.template.ts"],"names":[],"mappings":""}
@@ -1,174 +0,0 @@
1
- /**
2
- * Docker Infrastructure Test Template
3
- *
4
- * Copy and customize this file to test your project's Dockerfile and entrypoint.
5
- * Replace {{PROJECT_NAME}} and {{PROJECT_IMAGE}} with your values.
6
- *
7
- * This template demonstrates Harpoon's complete API for testing Docker infrastructure:
8
- * - Image building with buildArgs
9
- * - Container creation with volumes, capabilities, and user overrides
10
- * - Log waiting and streaming
11
- * - Command execution inside containers
12
- * - Network isolation testing
13
- *
14
- * @example
15
- * ```bash
16
- * # Copy and customize for your project
17
- * cp docker-infra.template.ts my-project.test.ts
18
- * # Edit PROJECT config and tests
19
- * bun test my-project.test.ts
20
- * ```
21
- */
22
- import { describe, test, expect, beforeAll, afterEach, setDefaultTimeout } from 'bun:test';
23
- import { Image, Container, Network, destroyAll } from '@docker-harpoon/core';
24
- // ============ PROJECT CONFIGURATION ============
25
- // Customize these values for your project
26
- const PROJECT = {
27
- name: '{{PROJECT_NAME}}',
28
- image: '{{PROJECT_IMAGE}}:latest',
29
- context: './',
30
- dockerfile: 'Dockerfile',
31
- port: 3000,
32
- healthPath: '/api/status',
33
- };
34
- // Set a generous timeout for Docker operations
35
- setDefaultTimeout(120_000);
36
- describe(`${PROJECT.name} Docker Infrastructure`, () => {
37
- beforeAll(async () => {
38
- // Build the project image
39
- await Image(PROJECT.image, {
40
- context: PROJECT.context,
41
- dockerfile: PROJECT.dockerfile,
42
- buildArgs: { SEED_DATABASE: 'true' },
43
- });
44
- });
45
- afterEach(async () => {
46
- await destroyAll();
47
- });
48
- // ============ HEALTH CHECK TEST ============
49
- test('health check responds 200', async () => {
50
- const container = await Container('test-health', {
51
- image: PROJECT.image,
52
- env: { PORT: String(PROJECT.port) },
53
- ports: [{ internal: PROJECT.port, external: 13000 }],
54
- });
55
- await container.waitForLog(/listening|started|ready/i, 30000);
56
- const res = await fetch(`http://localhost:13000${PROJECT.healthPath}`);
57
- expect(res.status).toBe(200);
58
- });
59
- // ============ VOLUME MOUNT TEST ============
60
- test('db snapshot copy-on-boot pattern', async () => {
61
- const container = await Container('test-snapshot', {
62
- image: PROJECT.image,
63
- env: {
64
- DB_SOURCE: '/data/snapshot/app.db',
65
- DB_PATH: '/app/data/test.db',
66
- },
67
- volumes: [
68
- { hostPath: '/tmp/test-snapshot.db', containerPath: '/data/snapshot/app.db', readonly: true },
69
- ],
70
- });
71
- await container.waitForLog(/snapshot copied|database ready/i, 30000);
72
- });
73
- // ============ FILE SYSTEM TEST ============
74
- test('file upload directory setup', async () => {
75
- const container = await Container('test-uploads', {
76
- image: PROJECT.image,
77
- env: { FILE_UPLOAD_PATH: '/app/custom-uploads' },
78
- });
79
- await container.waitForLog(/upload directory|ensuring/i, 10000);
80
- const result = await container.exec(['ls', '-la', '/app/custom-uploads']);
81
- expect(result.exitCode).toBe(0);
82
- expect(result.stdout).toContain('drwx'); // Directory exists with permissions
83
- });
84
- // ============ NETWORK ISOLATION TEST ============
85
- test('network isolation with iptables', async () => {
86
- const network = await Network('isolated-net');
87
- const container = await Container('test-isolation', {
88
- image: PROJECT.image,
89
- networks: [network],
90
- env: { ENABLE_NETWORK_ISOLATION: 'true' },
91
- capAdd: ['NET_ADMIN'],
92
- });
93
- await container.waitForLog(/network isolation configured|iptables/i, 15000);
94
- });
95
- // ============ PRIVILEGE DROPPING TEST ============
96
- test('privilege dropping', async () => {
97
- const container = await Container('test-privileges', {
98
- image: PROJECT.image,
99
- });
100
- await container.waitForLog(/dropping privileges|started/i, 15000);
101
- const result = await container.exec(['whoami']);
102
- expect(result.exitCode).toBe(0);
103
- expect(result.stdout.trim()).not.toBe('root');
104
- });
105
- // ============ ENVIRONMENT VARIABLE TEST ============
106
- test('environment variable propagation', async () => {
107
- const container = await Container('test-env', {
108
- image: PROJECT.image,
109
- env: {
110
- PORT: '8080',
111
- LOG_LEVEL: 'debug',
112
- CUSTOM_VAR: 'test-value',
113
- },
114
- ports: [{ internal: 8080, external: 18080 }],
115
- });
116
- await container.waitForLog(/listening|started/i, 30000);
117
- // Verify env vars are set
118
- const envResult = await container.exec(['printenv']);
119
- expect(envResult.stdout).toContain('PORT=8080');
120
- expect(envResult.stdout).toContain('LOG_LEVEL=debug');
121
- expect(envResult.stdout).toContain('CUSTOM_VAR=test-value');
122
- });
123
- // ============ USER OVERRIDE TEST ============
124
- test('user override', async () => {
125
- const container = await Container('test-user', {
126
- image: PROJECT.image,
127
- user: '1000:1000',
128
- });
129
- await container.waitForLog(/started|ready/i, 15000);
130
- const result = await container.exec(['id']);
131
- expect(result.exitCode).toBe(0);
132
- expect(result.stdout).toContain('uid=1000');
133
- expect(result.stdout).toContain('gid=1000');
134
- });
135
- // ============ CAPABILITIES TEST ============
136
- test('dropped capabilities', async () => {
137
- const container = await Container('test-caps', {
138
- image: PROJECT.image,
139
- capDrop: ['ALL'],
140
- capAdd: ['NET_BIND_SERVICE'],
141
- });
142
- await container.waitForLog(/started|ready/i, 15000);
143
- // Container should be running with minimal capabilities
144
- const result = await container.exec(['cat', '/proc/1/status']);
145
- expect(result.exitCode).toBe(0);
146
- // CapEff should show limited capabilities
147
- expect(result.stdout).toContain('CapEff');
148
- });
149
- // ============ GRACEFUL SHUTDOWN TEST ============
150
- test('graceful shutdown', async () => {
151
- const container = await Container('test-shutdown', {
152
- image: PROJECT.image,
153
- env: { PORT: String(PROJECT.port) },
154
- });
155
- await container.waitForLog(/listening|started|ready/i, 30000);
156
- const metadata = await container.stop('SIGTERM', 10000);
157
- expect(metadata.graceful).toBe(true);
158
- expect(metadata.signal).toBe('SIGTERM');
159
- });
160
- // ============ RESOURCE STATS TEST ============
161
- test('container stats', async () => {
162
- const container = await Container('test-stats', {
163
- image: PROJECT.image,
164
- env: { PORT: String(PROJECT.port) },
165
- });
166
- await container.waitForLog(/listening|started|ready/i, 30000);
167
- const stats = await container.stats();
168
- expect(stats.cpu).toBeDefined();
169
- expect(stats.cpu.percent).toBeGreaterThanOrEqual(0);
170
- expect(stats.memory).toBeDefined();
171
- expect(stats.memory.usage).toBeGreaterThan(0);
172
- expect(stats.network).toBeDefined();
173
- });
174
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * Network Resource Integration Tests
3
- *
4
- * Dogfoods the Network resource to verify:
5
- * - Creation and destruction
6
- * - Property access (id, name)
7
- * - Duplicate network handling
8
- */
9
- export {};
10
- //# sourceMappingURL=network.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"network.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/network.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,44 +0,0 @@
1
- /**
2
- * Network Resource Integration Tests
3
- *
4
- * Dogfoods the Network resource to verify:
5
- * - Creation and destruction
6
- * - Property access (id, name)
7
- * - Duplicate network handling
8
- */
9
- import { describe, test, expect, afterEach, setDefaultTimeout } from 'bun:test';
10
- import { Network, destroyAll } from '../index';
11
- setDefaultTimeout(30_000);
12
- describe('Network', () => {
13
- afterEach(async () => {
14
- await destroyAll();
15
- });
16
- test('creates a network and returns resource with id and name', async () => {
17
- const network = await Network('test-network-basic');
18
- expect(network.id).toBeDefined();
19
- expect(network.id.length).toBeGreaterThan(0);
20
- expect(network.name).toBe('test-network-basic');
21
- await network.destroy();
22
- });
23
- test('allows custom driver configuration', async () => {
24
- const network = await Network('test-network-custom', {
25
- driver: 'bridge',
26
- });
27
- expect(network.name).toBe('test-network-custom');
28
- expect(network.id).toBeDefined();
29
- await network.destroy();
30
- });
31
- test('handles creating network with same name (replaces existing)', async () => {
32
- const network1 = await Network('test-network-duplicate');
33
- const id1 = network1.id;
34
- const network2 = await Network('test-network-duplicate');
35
- const id2 = network2.id;
36
- expect(id2).not.toBe(id1);
37
- await network2.destroy();
38
- });
39
- test('destroy is idempotent', async () => {
40
- const network = await Network('test-network-idempotent');
41
- await network.destroy();
42
- expect(network.destroy()).resolves.toBeUndefined();
43
- });
44
- });
@@ -1,9 +0,0 @@
1
- /**
2
- * Shared test setup for integration tests.
3
- *
4
- * Builds a minimal test image that can be used across all tests,
5
- * ensuring tests are self-contained and don't rely on external images.
6
- */
7
- export declare const TEST_IMAGE = "harpoon-test:latest";
8
- export declare function buildTestImage(): Promise<void>;
9
- //# sourceMappingURL=test-setup.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-setup.d.ts","sourceRoot":"","sources":["../../src/__tests__/test-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,eAAO,MAAM,UAAU,wBAAwB,CAAC;AAWhD,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAapD"}
@@ -1,27 +0,0 @@
1
- /**
2
- * Shared test setup for integration tests.
3
- *
4
- * Builds a minimal test image that can be used across all tests,
5
- * ensuring tests are self-contained and don't rely on external images.
6
- */
7
- import { Image } from '../index';
8
- import { join } from 'path';
9
- export const TEST_IMAGE = 'harpoon-test:latest';
10
- let imageBuilt = false;
11
- // Get the source directory path (works in both ESM and CJS)
12
- const getFixturesDir = () => {
13
- // Try to resolve from source directory first
14
- const srcDir = join(process.cwd(), 'src', '__tests__', 'fixtures');
15
- return srcDir;
16
- };
17
- export async function buildTestImage() {
18
- if (imageBuilt) {
19
- return;
20
- }
21
- const fixturesDir = getFixturesDir();
22
- await Image(TEST_IMAGE, {
23
- context: fixturesDir,
24
- dockerfile: 'Dockerfile',
25
- });
26
- imageBuilt = true;
27
- }