File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Simple HTTP server to save artifacts
6
6
- [ Usage] ( #usage )
7
7
- [ Authentication] ( #authentication )
8
8
- [ TLS] ( #tls )
9
+ - [ Testing] ( #testing )
9
10
- [ API] ( #api )
10
11
- [ ` POST /upload ` ] ( #post-upload )
11
12
- [ ` PUT /files/:path ` ] ( #put-filespath )
@@ -78,6 +79,30 @@ v1 has TLS support but I decided to omit it from v2.
78
79
79
80
Please consider using a reverse proxy like nginx.
80
81
82
+ ## Testing
83
+
84
+ To run all tests, just run ` go test ` as usual:
85
+
86
+ ```
87
+ $ go test ./...
88
+ ```
89
+
90
+ This includes end-to-end tests. By default, the server with on-memory FileSystem is created and it starts listening on
91
+ the port chosen randomly. You can control this behavior by setting the environment variables.
92
+
93
+ If ` TEST_WITH_REAL_FS=${PATH_TO_DOCUMENT_ROOT} ` is set, the test server uses the real filesystem. Make sure the document
94
+ root directory contains no files; otherwise, some tests might be failed. The directory will not be cleaned after testing.
95
+
96
+ If ` TEST_TARGET_ADDR-${HOST}:${PORT} ` is set, the test program doesn't start a local test server and sends requests to
97
+ ` http://${HOST}:${PORT} ` . Note that the target server's document root should be cleared prior to testing.
98
+
99
+ This repository has ` docker-compose.e2e.yml ` to run the E2E test. To run tests using this:
100
+
101
+ ```
102
+ $ docker compose -f docker-compose.e2e.yml run --rm test
103
+ $ docker compose -f docker-compose.e2e.yml down --rmi local --volumes
104
+ ```
105
+
81
106
## API
82
107
83
108
### ` POST /upload `
Original file line number Diff line number Diff line change
1
+ services :
2
+ app :
3
+ build :
4
+ context : .
5
+ tags :
6
+ - " mayth/simple-upload-server:testing"
7
+ ports :
8
+ - " 127.0.0.1::8080"
9
+ volumes :
10
+ - docroot:/docroot
11
+ command : -document_root=/docroot -addr=:8080
12
+ test :
13
+ image : golang:1.21
14
+ environment :
15
+ - TEST_WITH_REAL_FS=/docroot
16
+ - TEST_TARGET_ADDR=app:8080
17
+ volumes :
18
+ - .:/app
19
+ - docroot:/docroot
20
+ working_dir : /app
21
+ command : go test -v -run TestServer ./...
22
+ depends_on :
23
+ - app
24
+ volumes :
25
+ docroot :
You can’t perform that action at this time.
0 commit comments