This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use assert.NoError instead of assert.Nil This gives nicer error messages. * Swap arguments to assert.Equal The expectation comes first. Otherwise, error messages will be misleading. An example: === RUN TestDeleteWithIncorrectRepoForDeleteCaches Error: authentication token not found for host github.com delete_test.go:56: Error Trace: /build/source/cmd/delete_test.go:56 Error: Should be true Test: TestDeleteWithIncorrectRepoForDeleteCaches Messages: 1 unmatched mocks: https://api.github.com/repos/testOrg/testRepo/actions/caches?key=cacheName delete_test.go:59: Error Trace: /build/source/cmd/delete_test.go:59 Error: Not equal: expected: "authentication token not found for host github.com" actual : "The given repo does not exist." Diff: --- Expected +++ Actual @@ -1 +1 @@ -authentication token not found for host github.com +The given repo does not exist. Test: TestDeleteWithIncorrectRepoForDeleteCaches --- FAIL: TestDeleteWithIncorrectRepoForDeleteCaches (0.00s) * Use assert.Error instead of assert.NotNil This gives nicer error messages. * Use assert.ErrorAs and assert.ErrorContains This simplifies the assertions and potentially gives better error messages. * Use require instead of assert and use assert.NotNil as guard This is to prevent panics in tests, when things get accessed which shouldn't be nil.
- Loading branch information
Showing
4 changed files
with
87 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.