Skip to content

Conversation

@edwardrf
Copy link
Contributor

@edwardrf edwardrf commented Jan 22, 2026

Description

So the compose test would run consistently irrespective what is the default folder mode of the checked out source code.

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Summary by CodeRabbit

  • Tests
    • Standardized test directory permissions to ensure consistent file/directory modes before running tests.
    • Replaced hard-coded test paths with a dynamic test context to improve reliability.
    • Minor test improvements and import updates to enhance robustness and debugging of the test suite.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Tests updated to set up a local context variable and to standardize filesystem permissions for the testdata directory by adding a standardizeDirMode helper (note: the helper was added twice in the file).

Changes

Cohort / File(s) Summary
Test + helper
src/pkg/cli/compose/context_test.go
Added fmt import; replaced hard-coded "../../../testdata/testproj" with a local context variable; introduced standardizeDirMode(dir string) error to chmod root/dirs to 0755 and files to 0644 via os.Chmod and fs.WalkDir, and call it before using the test context. The helper appears duplicated later in the file.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through folders late at night,
I nudged the modes to make tests right,
I swapped a path for one local and neat,
Danced with a helper — then copied my feet,
Now quiet tests hum soft and bright ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: standardizing file and directory modes for the context test to ensure consistent test execution.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.5.0)

level=warning msg="[linters_context] running gomodguard failed: unable to read module file go.mod: current working directory must have a go.mod file: if you are not using go modules it is suggested to disable this linter"
level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/pkg/cli/compose/context_test.go`:
- Line 19: Remove the unused import "github.com/DefangLabs/defang/src/pkg/term"
(the symbol term) from the import block in the test file so the package builds
cleanly; locate the import statement referencing term in context_test.go and
delete that import entry (or reformat the import block to only include used
packages).
🧹 Nitpick comments (1)
src/pkg/cli/compose/context_test.go (1)

256-259: Consider restoring original permissions with t.Cleanup.

Calling standardizeDirMode on the actual testdata directory modifies repository files permanently. This could leave the repo in a modified state after tests run (git may show permission changes). Consider saving and restoring original permissions, or copying the testdata to a temp directory first.

Option: Use a temp directory copy
// Copy testdata to temp dir to avoid modifying repo files
context := t.TempDir()
if err := copyDir("../../../testdata/testproj", context); err != nil {
    t.Fatalf("Failed to copy testdata: %v", err)
}
if err := standardizeDirMode(context); err != nil {
    t.Fatalf("Failed to standardize directory modes: %v", err)
}

@lionello lionello merged commit 064372d into main Jan 23, 2026
14 checks passed
@lionello lionello deleted the edw/fix-compose-test-mode branch January 23, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants