Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add e2e tests for issue #681 #683

Merged
merged 1 commit into from
Aug 3, 2023
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
29 changes: 16 additions & 13 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
version: "3"

tasks:
test:
cmds:
- go test -v -coverprofile=coverage.txt ./...
desc: run unit tests
sources:
- "**/*.go"
generates:
- coverage.txt

coverage:
deps: [test]
desc: run unit tests and create HTML coverage file
Expand All @@ -23,14 +14,14 @@ tasks:
cmds:
- go fmt ./...

rm_mocks:
mocks.remove:
desc: remove all mock files
cmds:
- find . -name '*_mock.go' | xargs rm
- rm -rf mocks/

mocks:
mocks.generate:
desc: generate mockery mocks
deps: [rm_mocks]
cmds:
- go run .

Expand All @@ -41,6 +32,8 @@ tasks:

mkdocs.install:
desc: install mkdocs and plugins
sources:
- "docs/requirements.txt"
cmds:
- pip install -r docs/requirements.txt

Expand All @@ -57,6 +50,15 @@ tasks:
cmds:
- go run github.com/golangci/golangci-lint/cmd/golangci-lint run

test:
cmds:
- go test -v -coverprofile=coverage.txt ./...
desc: run unit tests
sources:
- "**/*.go"
generates:
- coverage.txt

test.e2e:
desc: run end-to-end tests
sources:
Expand All @@ -68,7 +70,8 @@ tasks:
test.ci:
deps: [fmt, lint]
cmds:
- task: mocks
- task: mocks.remove
- task: mocks.generate
- task: test
- task: test.e2e

Expand Down
5 changes: 5 additions & 0 deletions e2e/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

for file in $(ls $SCRIPT_DIR/test_*.sh); do
echo "=========="
echo "RUNNING $file"
echo "=========="
go run github.com/go-task/task/v3/cmd/task mocks.remove || exit 1
go run github.com/go-task/task/v3/cmd/task mocks.generate || exit 1
$file
done
7 changes: 1 addition & 6 deletions e2e/test_infinite_mocking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@
# This tests https://github.com/vektra/mockery/issues/632, where
# mockery was generating mocks of its own auto-generated code.

echo "=========="
echo "RUNNING $0"
echo "=========="

# New mocks may legimitately be created, so we run mockery once first
go run .
num_files_before=$(find . -type f | wc -l)
go run .
go run github.com/go-task/task/v3/cmd/task mocks.generate
num_files_after=$(find . -type f | wc -l)

if [ $num_files_before -ne $num_files_after ]; then
Expand Down
6 changes: 1 addition & 5 deletions e2e/test_mockery_generation.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#!/bin/bash

echo "=========="
echo "RUNNING $0"
echo "=========="

go run .
go run github.com/go-task/task/v3/cmd/task mocks.generate
rt=$?
if [ $rt -ne 0 ]; then
echo "ERROR: non-zero return code from mockery"
Expand Down
8 changes: 8 additions & 0 deletions e2e/test_recursive_package_with_only_autogenerated_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# This tests https://github.com/vektra/mockery/pull/682

FILE="pkg/fixtures/recursive_generation/subpkg_with_only_autogenerated_files/Foo_mock.go"
if ! [ -f $FILE ]; then
echo "ERROR: $FILE does not exist"
exit 1
fi
36 changes: 36 additions & 0 deletions go.work.sum

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.