Skip to content

Commit

Permalink
Merge pull request #683 from LandonTClipp/issue_681_e2e
Browse files Browse the repository at this point in the history
Add e2e tests for issue #681
  • Loading branch information
LandonTClipp authored Aug 3, 2023
2 parents dbad753 + 871f904 commit 2046503
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 24 deletions.
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.

0 comments on commit 2046503

Please sign in to comment.