Skip to content

test: add --proxy-logs-dir edge case coverage#1220

Open
Mossaka wants to merge 2 commits intomainfrom
fix/069-proxy-logs-dir-tests
Open

test: add --proxy-logs-dir edge case coverage#1220
Mossaka wants to merge 2 commits intomainfrom
fix/069-proxy-logs-dir-tests

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Mar 11, 2026

Summary

  • Add 5 new unit tests for the --proxy-logs-dir flag covering missing edge cases
  • Tests cover API proxy logs sibling directory volume mounts, recursive directory creation, cleanup behavior (logs stay in place vs moved to /tmp), and API proxy logs chmod during cleanup
  • All 845 tests pass

Fixes #499

Test plan

  • npm run build passes
  • npm test passes (845 tests)
  • npm run lint passes (0 errors)
  • New tests verify generateDockerCompose, writeConfigs, and cleanup behavior with proxyLogsDir

🤖 Generated with Claude Code

Add 5 new tests for the --proxy-logs-dir flag covering:
- API proxy logs sibling directory volume mount (with/without proxyLogsDir)
- Recursive creation of nested proxyLogsDir parents
- Logs not moved to /tmp when proxyLogsDir is specified
- API proxy logs sibling chmod during cleanup

Fixes #499

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 11, 2026 01:07
@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 82.37% 82.65% 📈 +0.28%
Statements 82.27% 82.55% 📈 +0.28%
Functions 82.60% 82.60% ➡️ +0.00%
Branches 74.21% 74.39% 📈 +0.18%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.4% → 84.5% (+1.08%) 82.8% → 83.8% (+1.04%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional unit test coverage around the --proxy-logs-dir flag behavior, ensuring Squid and api-proxy log directory handling is correct across compose generation, config writing, and cleanup.

Changes:

  • Add generateDockerCompose tests for api-proxy log volume mounts with/without proxyLogsDir.
  • Add writeConfigs tests for creating the api-proxy sibling logs directory and recursive creation of nested proxyLogsDir paths.
  • Add cleanup tests to ensure logs aren’t moved when proxyLogsDir is used and that sibling api-proxy-logs gets chmod’d.
Comments suppressed due to low confidence (1)

src/docker-manager.test.ts:2607

  • Same as above: Date.now()-based temp directory names can collide and make the test flaky under parallel runs. Use fs.mkdtempSync(...) to create a unique externalDir for the test.
      const externalDir = path.join(os.tmpdir(), `awf-proxy-logs-test-${Date.now()}`);
      const proxyLogsDir = path.join(externalDir, 'proxy-logs');
      const apiProxyLogsDir = path.join(externalDir, 'api-proxy-logs');

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2588 to +2590
const externalDir = path.join(os.tmpdir(), `awf-proxy-logs-test-${Date.now()}`);
const proxyLogsDir = path.join(externalDir, 'proxy-logs');
fs.mkdirSync(proxyLogsDir, { recursive: true });
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Date.now() to generate externalDir can collide when tests run in parallel or when the same millisecond is reused, which can cause flaky failures (EEXIST / unexpected cleanup interactions). Prefer fs.mkdtempSync(path.join(os.tmpdir(), 'awf-proxy-logs-test-')) (or similar) for a guaranteed-unique temp directory, consistent with other tests in this file.

This issue also appears on line 2605 of the same file.

Copilot uses AI. Check for mistakes.
Comment on lines +1387 to +1392
it('should use sibling api-proxy-logs directory when proxyLogsDir is specified', () => {
const config: WrapperConfig = {
...mockConfig,
proxyLogsDir: '/custom/proxy/logs',
enableApiProxy: true,
openaiApiKey: 'sk-test-key',
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says this adds 5 new unit tests, but this diff appears to introduce 6 new it(...) cases (2 in generateDockerCompose, 2 in writeConfigs, 2 in cleanup). Consider updating the PR description (or dropping/combining a test) so the summary matches the changes.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Smoke test results for run 22931715733 — @Mossaka

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot for issue #1220

@github-actions
Copy link
Contributor

PR titles (merged, latest):

  • fix(squid): block direct IP connections that bypass domain filtering
  • feat: combine all build-test workflows into single build-test.md
    Tests: GitHub MCP review ✅ | safeinputs-gh pr list ✅ | Playwright title ✅ | Tavily search ❌ | file write+cat ✅ | discussion comment ✅ | build ✅
    Overall: FAIL

🔮 The oracle has spoken through Smoke Codex for issue #1220

@github-actions
Copy link
Contributor

Smoke Test Results

Test Status
GitHub MCP: #1160 fix(squid): block direct IP connections that bypass domain filtering
GitHub MCP: #1157 feat: combine all build-test workflows into single build-test.md
Playwright: github.com title contains "GitHub"
File write + verify

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1220

@github-actions
Copy link
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.12 Python 3.12.3 ❌ NO
Node.js v24.14.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot for issue #1220

@github-actions

This comment has been minimized.

Replace manual Date.now()-based temp dir construction with
fs.mkdtempSync() to satisfy CodeQL insecure-temporary-file checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Smoke test results for @Mossaka (no assignees):

✅ GitHub MCP — Last 2 merged PRs: fix(squid): block direct IP connections that bypass domain filtering (#1160), feat: combine all build-test workflows into single build-test.md (#1157)
✅ Playwright — https://github.com title contains "GitHub"
✅ File write — /tmp/gh-aw/agent/smoke-test-copilot-22931934007.txt created and verified
✅ Bash tool — cat confirmed file contents

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot for issue #1220

@github-actions
Copy link
Contributor

Smoke Test Results

Test Status
GitHub MCP: #1160 fix(squid): block direct IP connections
GitHub MCP: #1099 feat: add skip-cleanup flag
Playwright: github.com title contains "GitHub"
File write/read: smoke-test-claude-22931933989.txt

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1220

@github-actions
Copy link
Contributor

PR titles: test: add --allow-host-ports validation tests | test: add --proxy-logs-dir edge case coverage
Tests: GitHub MCP ✅; safeinputs-gh ✅; Playwright ✅; Tavily ❌; file write ✅; bash cat ✅; discussion comment ✅; build ✅
Merged PRs reviewed: #1160, #1157
Notes: Tavily search tool unavailable in this environment
Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex for issue #1220

@github-actions
Copy link
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.12 Python 3.12.3 ❌ NO
Node.js v24.14.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall: FAILED — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot for issue #1220

@github-actions
Copy link
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #1220 ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add tests for --proxy-logs-dir flag

2 participants