You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add WriteTestFile function for creating temporary test files
- Add MockHTTPServer for easy HTTP server testing
- Add HTTPRequestCaptor for inspecting HTTP requests in tests
- Enhance README with new utilities and examples
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardexpand all lines: README.md
+121-10
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,132 @@ Package `testutils` provides useful test helpers.
4
4
5
5
## Details
6
6
7
-
-`CaptureStdout`, `CaptureSterr` and `CaptureStdoutAndStderr`: capture stdout, stderr or both for testing purposes. All capture functions are not thread-safe if used in parallel tests, and usually it is better to pass a custom io.Writer to the function under test instead.
7
+
### Capture Utilities
8
8
9
-
-`containers`: provides test containers for integration testing:
10
-
-`SSHTestContainer`: SSH server container for testing SSH connections and operations
11
-
-`PostgresTestContainer`: PostgreSQL database container with automatic database creation
12
-
-`MySQLTestContainer`: MySQL database container with automatic database creation
13
-
-`MongoTestContainer`: MongoDB container with support for multiple versions (5, 6, 7)
14
-
-`LocalstackTestContainer`: LocalStack container with S3 service for AWS testing
9
+
-`CaptureStdout`: Captures stdout output from the provided function
10
+
-`CaptureStderr`: Captures stderr output from the provided function
11
+
-`CaptureStdoutAndStderr`: Captures both stdout and stderr from the provided function
12
+
13
+
These capture utilities are useful for testing functions that write directly to stdout/stderr. They redirect the standard outputs to a buffer and return the captured content as a string.
14
+
15
+
**Important Note**: The capture functions are not thread-safe if used in parallel tests. For concurrent tests, it's better to pass a custom io.Writer to the function under test instead.
16
+
17
+
### File Utilities
18
+
19
+
-`WriteTestFile`: Creates a temporary file with specified content and returns its path. The file is automatically cleaned up after the test completes.
20
+
21
+
### HTTP Test Utilities
22
+
23
+
-`MockHTTPServer`: Creates a test HTTP server with the given handler. Returns the server URL and a cleanup function.
24
+
-`HTTPRequestCaptor`: Returns a request captor and an HTTP handler that captures and records HTTP requests for later inspection.
25
+
26
+
### Test Containers
27
+
28
+
The `containers` package provides several test containers for integration testing:
29
+
30
+
-`SSHTestContainer`: SSH server container for testing SSH connections and operations
31
+
-`PostgresTestContainer`: PostgreSQL database container with automatic database creation
32
+
-`MySQLTestContainer`: MySQL database container with automatic database creation
33
+
-`MongoTestContainer`: MongoDB container with support for multiple versions (5, 6, 7)
34
+
-`LocalstackTestContainer`: LocalStack container with S3 service for AWS testing
0 commit comments