Skip to content

Commit 745bd25

Browse files
authored
fix: display test snapshot error message (#4091)
1 parent 015cd0d commit 745bd25

File tree

8 files changed

+76
-83
lines changed

8 files changed

+76
-83
lines changed

.github/workflows/code-health.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ jobs:
317317
config: ${{ vars.PERMISSIONS_CONFIG }}
318318
- name: Checkout repository
319319
uses: actions/checkout@v4
320-
with:
321-
fetch-depth: 0
322320
- name: Install Go
323321
uses: actions/setup-go@v5
324322
with:
@@ -332,7 +330,14 @@ jobs:
332330
with:
333331
app-id: ${{ secrets.APIXBOT_APP_ID }}
334332
private-key: ${{ secrets.APIXBOT_APP_PEM }}
335-
- run: make e2e-test-snapshots
333+
- run: |
334+
set +e
335+
make e2e-test-snapshots
336+
EXIT_CODE=$?
337+
if [ $EXIT_CODE -ne 0 ]; then
338+
echo "::error::Snapshot tests failed, consider adding label 'update-snapshots' to re-generate them"
339+
fi
340+
exit $EXIT_CODE
336341
env:
337342
GH_TOKEN: ${{ steps.app-token.outputs.token }}
338343
TEST_CMD: gotestsum --junitfile e2e-tests.xml --format standard-verbose --

.github/workflows/update-e2e-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
- run: make e2e-test
7979
env:
8080
TEST_CMD: gotestsum --junitfile e2e-tests.xml --format standard-verbose --
81-
E2E_TEST_PACKAGES: ./test/e2e/{{ matrix.packages }}..
81+
E2E_TEST_PACKAGES: ./test/e2e/{{ matrix.packages }}/...
8282
MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }}
8383
MONGODB_ATLAS_PROJECT_ID: ${{ secrets.MONGODB_ATLAS_PROJECT_ID }}
8484
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_API_KEY }}
@@ -136,7 +136,7 @@ jobs:
136136
- run: make e2e-test
137137
env:
138138
TEST_CMD: gotestsum --junitfile e2e-tests.xml --format standard-verbose --
139-
E2E_TEST_PACKAGES: ./test/internal..
139+
E2E_TEST_PACKAGES: ./test/internal/...
140140
MONGODB_ATLAS_ORG_ID: ${{ secrets.MONGODB_ATLAS_ORG_ID }}
141141
MONGODB_ATLAS_PROJECT_ID: ${{ secrets.MONGODB_ATLAS_PROJECT_ID }}
142142
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_API_KEY }}

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
version: "2"
22
run:
3-
build-tags:
4-
- e2e
53
modules-download-mode: readonly
64
tests: true
75
linters:

CONTRIBUTING.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ We provide a git pre-commit hook to format and check the code, to install it run
7878
We use [mockgen](go.uber.org/mock) to handle mocking in our unit tests.
7979
If you need a new mock please update or add the `//go:generate` instruction to the appropriate file.
8080

81-
#### Compilation in VSCode
82-
83-
Please add the following line to your `.vscode/settings.json` file :
84-
```json
85-
{
86-
"go.buildTags": "e2e",
87-
"go.testTags": "e2e"
88-
}
89-
```
90-
91-
This will enable compilation for unit and end-to-end tests.
92-
9381
#### Debugging in VSCode
9482

9583
To debug in VSCode, you must create a debug configuration for the command with the required arguments.
@@ -136,8 +124,6 @@ Review and replace the atlas settings.
136124

137125
```json
138126
{
139-
"go.buildTags": "e2e",
140-
"go.testTags": "e2e",
141127
"go.testEnvVars": {
142128
"ATLAS_E2E_BINARY": "${workspaceFolder}/bin/atlas",
143129
"UPDATE_SNAPSHOTS": "skip",

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export SNAPSHOTS_DIR?=$(abspath test/e2e/testdata/.snapshots)
2525
DEBUG_FLAGS=all=-N -l
2626

2727
TEST_CMD?=go test
28-
E2E_TEST_PACKAGES?=./test/e2e..
28+
E2E_TEST_PACKAGES?=./test/e2e/...
2929
E2E_TIMEOUT?=60m
3030
E2E_PARALLEL?=1
3131
E2E_EXTRA_ARGS?=
@@ -174,11 +174,11 @@ build-debug: ## Generate a binary in ./bin for debugging atlascli
174174
e2e-test: build-debug ## Run E2E tests
175175
# the target assumes the MCLI_* environment variables are exported
176176
@echo "==> Running E2E tests..."
177-
$(TEST_CMD) -v -p 1 -parallel $(E2E_PARALLEL) -v -timeout $(E2E_TIMEOUT) ${E2E_TEST_PACKAGES}. $(E2E_EXTRA_ARGS)
177+
$(TEST_CMD) -v -p 1 -parallel $(E2E_PARALLEL) -v -timeout $(E2E_TIMEOUT) ${E2E_TEST_PACKAGES} $(E2E_EXTRA_ARGS)
178178

179179
.PHONY: e2e-test-snapshots
180180
e2e-test-snapshots: build-debug ## Run E2E tests
181-
UPDATE_SNAPSHOTS=false E2E_SKIP_CLEANUP=true DO_NOT_TRACK=1 $(TEST_CMD) -v -timeout $(E2E_TIMEOUT) ${E2E_TEST_PACKAGES}. $(E2E_EXTRA_ARGS)
181+
UPDATE_SNAPSHOTS=false E2E_SKIP_CLEANUP=true DO_NOT_TRACK=1 $(TEST_CMD) -v -timeout $(E2E_TIMEOUT) ${E2E_TEST_PACKAGES} $(E2E_EXTRA_ARGS)
182182
go tool covdata textfmt -i $(GOCOVERDIR) -o $(COVERAGE)
183183

184184
.PHONY: unit-test

0 commit comments

Comments
 (0)