Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

chore: replace log.Fatal with t.Fatal in tests #2066

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

alexandear
Copy link
Contributor

@alexandear alexandear commented Nov 25, 2024

This PR improves tests by replacing log.Fatal with t.Fatal. log.Fatal immediately interrupts all tests and call os.Exit(1), which does not run any deferred statements. t.Fatal interrupt only failed test, shows the line with failure, and ensures all deferred statements are run.

Compare outputs:

  1. log.Fatal:
=== RUN   TestGetIssue
2024/11/25 14:28:15 some error
  1. t.Fatal:
=== RUN   TestGetIssue
    /Users/Oleksandr_Redko/src/github.com/xanzy/go-gitlab/issues_test.go:37: some error
--- FAIL: TestMoveIssue (0.00s)

This was found with revive.deep-exit rule.

@alexandear alexandear changed the title chore: replace log.Fatal with t.Fatal chore: replace log.Fatal with t.Fatal in tests Nov 25, 2024
@RicePatrick
Copy link
Contributor

Looks good; great change! Thanks @alexandear 🎉

@RicePatrick RicePatrick merged commit c1ce518 into xanzy:main Nov 25, 2024
3 checks passed
@alexandear alexandear deleted the chore/t-fatal branch November 25, 2024 22:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants