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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
TZ: "America/Chicago"

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v7
with:
version: latest
version: v2.0.2

- name: install goveralls
run: go install github.com/mattn/goveralls@latest
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
*.cov

# Go workspace file
go.work

**/CLAUDE.local.md
61 changes: 61 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: "2"
run:
concurrency: 4
linters:
default: none
enable:
- copyloopvar
- gochecknoinits
- gocritic
- gosec
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- revive
- staticcheck
- unconvert
- unparam
- unused
- testifylint
- nestif
settings:
goconst:
min-len: 2
min-occurrences: 2
gocritic:
disabled-checks:
- wrapperFunc
enabled-tags:
- performance
- style
- experimental
gocyclo:
min-complexity: 15
lll:
line-length: 140
misspell:
locale: US
exclusions:
generated: lax
rules:
- linters:
- gosec
text: 'G114: Use of net/http serve function that has no support for setting timeouts'
- linters:
- revive
- unparam
path: _test\.go$
text: unused-parameter
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
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
}
}
```
1 change: 1 addition & 0 deletions capture.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package testutils provides utilities for testing Go applications
package testutils

import (
Expand Down
10 changes: 8 additions & 2 deletions capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ func TestCaptureStdoutAndStderr(t *testing.T) {
wantOut: string([]byte{0, 1, 2, 3}),
wantErr: string([]byte{4, 5, 6, 7}),
f: func() {
os.Stdout.Write([]byte{0, 1, 2, 3})
os.Stderr.Write([]byte{4, 5, 6, 7})
_, err := os.Stdout.Write([]byte{0, 1, 2, 3})
if err != nil {
t.Logf("failed to write to stdout: %v", err)
}
_, err = os.Stderr.Write([]byte{4, 5, 6, 7})
if err != nil {
t.Logf("failed to write to stderr: %v", err)
}
},
},
{
Expand Down
Loading
Loading