Skip to content
Open
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
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang:1.22-alpine
RUN apk update && apk add shadow
RUN groupadd -g 1000 test && useradd -u 1000 -g 1000 -m -d /usr/src/app test
WORKDIR /usr/src/app
COPY . .
RUN chown -R test:test .
USER test:test
CMD [ "go", "test", "./..." ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ To make a release of go-sftp simply open a pull request with `CHANGELOG.md` and

### Testing

We maintain a comprehensive suite of unit tests and recommend table-driven testing when a particular function warrants several very similar test cases. After starting the services with Docker Compose run all tests with `go test ./...`. Current overall coverage can be found on [Codecov](https://app.codecov.io/gh/moov-io/go-sftp/).
We maintain a comprehensive suite of unit tests and recommend table-driven testing when a particular function warrants several very similar test cases. Run tests with `docker compose up --abort-on-container-exit --exit-code-from testrunner`. Current overall coverage can be found on [Codecov](https://app.codecov.io/gh/moov-io/go-sftp/).

## License

Expand Down
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestClient(t *testing.T) {
}

client, err := sftp.NewClient(log.NewTestLogger(), &sftp.ClientConfig{
Hostname: "localhost:2222",
Hostname: "sftp:22",
Username: "demo",
Password: "password",
Timeout: 5 * time.Second,
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestClient__UploadFile(t *testing.T) {
}

conf := &sftp.ClientConfig{
Hostname: "localhost:2222",
Hostname: "sftp:22",
Username: "demo",
Password: "password",
Timeout: 5 * time.Second,
Expand Down
21 changes: 19 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
version: '3.7'

networks:
test-net: {}

services:
sftp:
image: atmoz/sftp:latest
ports:
- "2222:22"
volumes:
- "./testdata/outbox:/home/demo/outbox"
- "./testdata/bigdata:/home/demo/bigdata"
- "./testdata/root.txt:/home/demo/root.txt"
command:
- "demo:password:::outbox,upload"
healthcheck:
test: ["CMD-SHELL", "bash -c 'exec 6<> /dev/tcp/localhost/22'"]
interval: 2s
networks:
- test-net

testrunner:
depends_on:
sftp:
condition: service_healthy
build:
context: .
dockerfile: Dockerfile
networks:
- test-net
2 changes: 1 addition & 1 deletion network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestNetwork(t *testing.T) {
}

client, err := sftp.NewClient(log.NewTestLogger(), &sftp.ClientConfig{
Hostname: "localhost:2222",
Hostname: "sftp:22",
Username: "demo",
Password: "password",
Timeout: 5 * time.Second,
Expand Down