Skip to content

Commit fb3b730

Browse files
Mossakaclaude
andcommitted
fix(test): remove duplicate extractLastJson local functions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ff7dab2 commit fb3b730

File tree

2 files changed

+0
-90
lines changed

2 files changed

+0
-90
lines changed

tests/integration/api-proxy-observability.test.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,6 @@ import { extractLastJson, extractCommandOutput } from '../fixtures/stdout-helper
1515
// The API proxy sidecar is at this fixed IP on the awf-net network
1616
const API_PROXY_IP = '172.30.0.30';
1717

18-
/**
19-
* Extract the last JSON object from stdout.
20-
*
21-
* When --build-local is used, Docker build output is mixed into stdout before
22-
* the actual command output. This helper finds the last complete top-level
23-
* JSON object in the output so that JSON.parse works reliably.
24-
*/
25-
function extractLastJson(stdout: string): unknown {
26-
// Find the last '{' that starts a top-level JSON object
27-
let depth = 0;
28-
let jsonEnd = -1;
29-
let jsonStart = -1;
30-
31-
// Scan backwards from end to find the last complete JSON object
32-
for (let i = stdout.length - 1; i >= 0; i--) {
33-
const ch = stdout[i];
34-
if (ch === '}') {
35-
if (depth === 0) jsonEnd = i;
36-
depth++;
37-
} else if (ch === '{') {
38-
depth--;
39-
if (depth === 0) {
40-
jsonStart = i;
41-
break;
42-
}
43-
}
44-
}
45-
46-
if (jsonStart === -1 || jsonEnd === -1) {
47-
throw new Error(`No JSON object found in stdout (length=${stdout.length}): ${stdout.slice(-200)}`);
48-
}
49-
50-
return JSON.parse(stdout.slice(jsonStart, jsonEnd + 1));
51-
}
52-
53-
/**
54-
* Extract the HTTP response section from stdout when curl -i is used.
55-
*
56-
* Docker build output appears before the HTTP response. This finds the last
57-
* HTTP response block (starting with "HTTP/") in stdout.
58-
*/
59-
function extractHttpResponse(stdout: string): string {
60-
// Find the last occurrence of an HTTP status line
61-
const httpPattern = /HTTP\/[\d.]+ \d+/g;
62-
let lastMatch: RegExpExecArray | null = null;
63-
let match: RegExpExecArray | null;
64-
while ((match = httpPattern.exec(stdout)) !== null) {
65-
lastMatch = match;
66-
}
67-
68-
if (lastMatch) {
69-
return stdout.slice(lastMatch.index);
70-
}
71-
72-
// Fallback: return the whole stdout
73-
return stdout;
74-
}
7518

7619
describe('API Proxy Observability', () => {
7720
let runner: AwfRunner;

tests/integration/api-proxy-rate-limit.test.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,6 @@ function extractHttpResponse(stdout: string): string {
3434
return stdout;
3535
}
3636

37-
/**
38-
* Extract the last JSON object from stdout.
39-
*
40-
* When --build-local is used, Docker build output is mixed into stdout before
41-
* the actual command output. This helper finds the last complete top-level
42-
* JSON object in the output so that JSON.parse works reliably.
43-
*/
44-
function extractLastJson(stdout: string): unknown {
45-
let depth = 0;
46-
let jsonEnd = -1;
47-
let jsonStart = -1;
48-
49-
for (let i = stdout.length - 1; i >= 0; i--) {
50-
const ch = stdout[i];
51-
if (ch === '}') {
52-
if (depth === 0) jsonEnd = i;
53-
depth++;
54-
} else if (ch === '{') {
55-
depth--;
56-
if (depth === 0) {
57-
jsonStart = i;
58-
break;
59-
}
60-
}
61-
}
62-
63-
if (jsonStart === -1 || jsonEnd === -1) {
64-
throw new Error(`No JSON object found in stdout (length=${stdout.length}): ${stdout.slice(-200)}`);
65-
}
66-
67-
return JSON.parse(stdout.slice(jsonStart, jsonEnd + 1));
68-
}
69-
7037
describe('API Proxy Rate Limiting', () => {
7138
let runner: AwfRunner;
7239

0 commit comments

Comments
 (0)