-
Notifications
You must be signed in to change notification settings - Fork 86
Add comprehensive test suite for file persistence and change tracking #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
environment/unit_test.go
Outdated
@@ -0,0 +1,210 @@ | |||
package environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the unit tests will conflict with #59, but not in a way that's hard to fix i don't think, just gotta move some shit around
dd281c8
to
88bc059
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @grouville, much appreciated! Some minor comments
@@ -0,0 +1,729 @@ | |||
package environment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: MAYBE we should move these into their own package, e.g. environment/integration
or something, keep the unit tests top-level. MAYBE. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo for small projects the thing he's doing with -short is quite nice and provides a similar test grouping UX. i'd like to try it out and see if there are other drawbacks that aren't yet obvious to me... the one i can see from here is it might be too easy to share helpers that turn unit tests into int tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: MAYBE we should move these into their own package, e.g.
environment/integration
or something, keep the unit tests top-level. MAYBE. Thoughts?
Regarding the integration tests: I’ve kept them in the environment package because they need access to the private functions to thoroughly verify the implementation. Moving them to a separate package (like environment_test or environment/integration) would limit testing to the public API only, reducing coverage (or requiring to turn more of those functions public. What would be your recommended approach (I don't mind) ?
0a223b7
to
67a1630
Compare
4038593
to
6f4ec13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, just need to decide whether this or #62 goes in first... conventional wisdom says tests go in first, but idk cc @aluzzardi
…al behaviors users rely on: * Persistence of work across sessions (files and changes remain intact through restarts). * Automatic change tracking and audit trails for effective debugging. * Graceful handling of problematic files, including Python cache, binary files, and large files. * Isolation of multiple environments to support safe parallel operations. * Reliable persistence of environment configuration (base images, setup commands). Detailed testing includes: * Git operations, specifically handling command errors, worktree paths, and empty directories. * Selective file staging to manage Python cache and binary files appropriately. * Verification of configuration persistence and environment isolation. Adopted a behavior-driven testing approach focusing on user-experienced behaviors rather than internal implementation details. Modified git.go to support test isolation via the `CONTAINER_USE_CONFIG_DIR` environment variable. Introduced test helpers to streamline the creation of isolated test environments. Documented known limitations clearly with skipped tests for currently unresolved issues related to Python cache, binary directories, and environment variables. Signed-off-by: Guillaume de Rouville <[email protected]>
make it work Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Updated the test to use commands that developers actually run: - Creating build directories (common in CI/CD) - Writing to build output logs (typical build process) - Creating coverage directories (test runners like pytest) These are more representative of real-world scenarios where commands produce no git-trackable changes but should still be audited. Related to issue dagger#82
The test now: - Simulates Python cache directories without needing Python installed - Verifies that development continues normally with __pycache__ present - Serves as a regression test for Python workflows - Renamed from PythonCache to PythonDevelopmentWorkflow for clarity The original bug appears to have been fixed - __pycache__ directories are properly ignored by git and don't interfere with operations.
Concurrency was properly implemented -- added a test showing that in a sequencial environment, every git operation is sequential and working Removed the impossible concurrency test Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Summary
Comprehensive test suite to ensure reliable file persistence, change tracking, and environment isolation in container-use.
Key Improvements
Core Functionality Tests
Test Coverage
Implementation Notes
git.go
to support test isolation viaCONTAINER_USE_CONFIG_DIR
Status
Ready for review
Note: Some edge cases (Python cache, binary directories, environment variables) are documented as skipped tests for future resolution.