Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ These capture utilities are useful for testing functions that write directly to
The `containers` package provides several test containers for integration testing:

- `SSHTestContainer`: SSH server container for testing SSH connections and operations
- `FTPTestContainer`: FTP server container for testing FTP file transfers and operations
- `PostgresTestContainer`: PostgreSQL database container with automatic database creation
- `MySQLTestContainer`: MySQL database container with automatic database creation
- `MongoTestContainer`: MongoDB container with support for multiple versions (5, 6, 7)
Expand Down Expand Up @@ -196,4 +197,35 @@ func TestWithS3(t *testing.T) {
})
require.NoError(t, err)
}

// FTP test container
func TestWithFTP(t *testing.T) {
ctx := context.Background()
ftpContainer := containers.NewFTPTestContainer(ctx, t)
defer ftpContainer.Close(ctx)

// Connection details
ftpHost := ftpContainer.GetIP() // Container host
ftpPort := ftpContainer.GetPort() // Container port (default: 2121)
ftpUser := ftpContainer.GetUser() // Default: "ftpuser"
ftpPassword := ftpContainer.GetPassword() // Default: "ftppass"

// Upload a file
localFile := "/path/to/local/file.txt"
remotePath := "file.txt"
err := ftpContainer.SaveFile(ctx, localFile, remotePath)
require.NoError(t, err)

// Download a file
downloadPath := "/path/to/download/location.txt"
err = ftpContainer.GetFile(ctx, remotePath, downloadPath)
require.NoError(t, err)

// List files
entries, err := ftpContainer.ListFiles(ctx, "/")
require.NoError(t, err)
for _, entry := range entries {
fmt.Println(entry.Name, entry.Type) // Type: 0 for file, 1 for directory
}
}
```
Loading
Loading