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

refactor: enhance test readability #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

refactor: enhance test readability #8

wants to merge 4 commits into from

Conversation

au-phiware
Copy link
Collaborator

  • chore: update to go 1.21

    Prior to this change, we using go 1.20.

    This change updates to go 1.21 and introduces the toolchain directive. With this update the tools.go file is no longer required for the test cases and it also highlighted some missing go mod tidy commands in the test cases.

  • refactor: remove sed dependency

    Prior to this change, sed was used to remove the coverage results and timing data from test output of the test cases (i.e. where a test invoked go test via rsc.io/script). This is important because the test not reproducible otherwise. However, complex regular expressions to do this is fragile and difficult to change.

    This change wraps the go test command in a custom rsc.io/script command; this allows us to filter the JSON formatted test output using a go function. Only the output relating to individual tests is outputed (i.e. summary information is excluded) and we generate our own result (i.e. pass/fail/skip) lines with the elapsed time removed. Also, we now automatically pass the correct -coverpkg and -test.gocoverdir arguments without the conditional bash variable expansion polluting every txt archive file.

  • chore: improve readability of test in GH actions

    Prior to this change, the test results are long and hard to see when one test ends and another starts.

    This change introduces gotestfmt tool which format go test output into coloured, collapsible sections. Also, the original JSON output is uploaded in case of any issues, along with the raw coverage data.

Prior to this change, the test results are long and hard to see when one
test ends and another starts.

This change introduces gotestfmt tool which format go test output into
coloured, collapsible sections.  Also, the original JSON output is uploaded in
case of any issues, along with the raw coverage data.
Prior to this change, sed was used to remove the coverage results and
timing data from test output of the test cases (i.e. where a test
invoked `go test` via rsc.io/script).  This is important because the
test not reproducible otherwise.  However, complex regular expressions
to do this is fragile and difficult to change.

This change wraps the go test command in a custom rsc.io/script command;
this allows us to filter the JSON formatted test output using a go
function.  Only the output relating to individual tests is outputed
(i.e. summary information is excluded) and we generate our own result
(i.e. pass/fail/skip) lines with the elapsed time removed.  Also, we now
automatically pass the correct -coverpkg and -test.gocoverdir arguments
without the conditional bash variable expansion polluting every txt
archive file.
Prior to this change, we using go 1.20.

This change updates to go 1.21 and introduces the toolchain directive.
With this update the tools.go file is no longer required for the test
cases and it also highlighted some missing go mod tidy commands in the
test cases.
Prior to this change, there were no test files for the package:
github.com/Versent/go-vermock/internal/cmd/vermockgen.

This change introduces limited tests for SetFlags and Execute methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant