Skip to content

Commit 61a3df3

Browse files
authored
refactor: replace custom test formatter with gotestsum (#380)
1 parent 706426c commit 61a3df3

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
- uses: actions/setup-go@v5
4747
with:
4848
go-version: "^1.25"
49+
- name: Install gotestsum
50+
run: go install gotest.tools/gotestsum@latest
4951
- name: Execute unit tests
5052
run: make test.backend.unit
5153
- name: Stash test results
@@ -81,6 +83,8 @@ jobs:
8183
- uses: actions/setup-go@v5
8284
with:
8385
go-version: "^1.25"
86+
- name: Install gotestsum
87+
run: go install gotest.tools/gotestsum@latest
8488
- name: Execute integration tests
8589
run: make test.backend.integration
8690
- name: Stash test results

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ test # Run all k6, backend and front-end tests
190190
## Code Quality and Tests
191191

192192
The project ensures code quality and code coverage in multiple ways. Besides third-party online tools, with the lack of
193-
completeness, `gofmt` `go-imports`, `golangci-lint`, `go test`, `k6`, `playwright` and `eslint` are used to keep up with
193+
completeness, `gofmt` `go-imports`, `golangci-lint`, `gotestsum`, `k6`, `playwright` and `eslint` are used to keep up with
194194
industry standards.
195195

196196
Although front-end unit tests are not created yet, linters and some end-to-end tests are available. In order to run

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ PNPM_RUN=$(PNPM_EXEC) run --prefix "$(ROOT_DIR)/web"
2222
PNPM_EMAILS_RUN=$(PNPM_EXEC) run --prefix "$(ROOT_DIR)/build/email"
2323

2424
GO_EXEC:=$(shell which go)
25-
GO_TEST_COVER=$(GO_EXEC) test -shuffle=on -cover -covermode=atomic -ldflags="-extldflags=-Wl,-ld_classic"
2625
GO_TEST_IGNORE:=(mode: atomic|testutil|tools|cmd|http\/api)
2726

2827
TMPDIR:=$(shell echo "${TMPDIR:-/tmp}")
@@ -165,13 +164,13 @@ test.backend.bench: ## Run backend benchmarks
165164
test.backend.unit: ## Run backend unit tests
166165
$(call log, execute backend unit tests)
167166
@rm -f "$(BACKEND_COVER_OUT_UNIT)"
168-
@bash -c '$(GO_TEST_COVER) -json -race -short -coverprofile="$(BACKEND_COVER_OUT_UNIT)" ./... 2>&1 | $(SCRIPTS_DIR)/pretty-test.sh; exit $${PIPESTATUS[0]}'
167+
@gotestsum --format testname -- -shuffle=on -cover -covermode=atomic -ldflags="-extldflags=-Wl,-ld_classic" -race -short -coverprofile="$(BACKEND_COVER_OUT_UNIT)" ./...
169168

170169
.PHONY: test.backend.integration
171170
test.backend.integration: ## Run backend integration tests
172171
$(call log, execute backend integration tests)
173172
@rm -f "$(BACKEND_COVER_OUT_INTEGRATION)"
174-
@bash -c '$(GO_TEST_COVER) -json -timeout 900s -run=Integration -coverprofile="$(BACKEND_COVER_OUT_INTEGRATION)" ./... 2>&1 | $(SCRIPTS_DIR)/pretty-test.sh; exit $${PIPESTATUS[0]}'
173+
@gotestsum --format testname -- -shuffle=on -cover -covermode=atomic -ldflags="-extldflags=-Wl,-ld_classic" -timeout 900s -run=Integration -coverprofile="$(BACKEND_COVER_OUT_INTEGRATION)" ./...
175174

176175
.PHONY: test.backend.coverage
177176
test.backend.coverage: ## Combine unit and integration test coverage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ on Linux, MacOS, or Windows WSL2. Follow the steps below and get ready to contri
7070

7171
```shell
7272
# Make sure you have all the development requirements installed, then run the setup script.
73-
# Requirements: yq, jq, go, openssl, docker (with compose plugin), make, nvm
73+
# Requirements: yq, jq, go, openssl, docker (with compose plugin), make, nvm, gotestsum
7474
./scripts/setup.sh
7575
```
7676

scripts/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ This script generates development configuration files and key.
1919
Takes the Open API specification in the `api/openapi` directory, and generates
2020
a TypeScript client from it.
2121

22-
## pretty-test.sh
23-
24-
Takes the JSON output of `go test` command and pretty-formats it using `jq` to
25-
make it more readable.
26-
2722
## setup.sh
2823

2924
This script prepares the whole development environment. Generates a new

scripts/pretty-test.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)