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

Tests cleanup #366

Merged
merged 2 commits into from
Mar 27, 2024
Merged

Tests cleanup #366

merged 2 commits into from
Mar 27, 2024

Commits on Mar 27, 2024

  1. Change Run() to RunT(t) in tests

    Goleak[1] found unclosed goroutines in tests, for example
    `miniredis_test.go:TestDump`[2] never calls `s.Close()`
    ```go
    func TestDump(t *testing.T) {
    	s, err := Run()
    	ok(t, err)
    	s.Set("aap", "noot")
    	s.Set("vuur", "mies")
    // ...
    }
    ```
    
    I've changed `Run()` calls to `RunT(t)` calls to:
     - ensure all goroutines all closed after test is finished
     - we have shorter tests (no need to check for error and close server
    
    There is no risk in using RunT even if test manually closes server
    because calling Close multiple times is not an issue.
    
    [1] http://go.uber.org/goleak
    [2] https://github.com/alicebob/miniredis/blob/9ac631e686635ffc17cb1fb45027b8a67f125c80/miniredis_test.go#L88-L129
    
    Signed-off-by: Wojciech Szarański <[email protected]>
    wszaranski committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    6bfc8c6 View commit details
    Browse the repository at this point in the history
  2. Move create of client in tests to helper function

    Removed duplicated code in tests using helper function.
    
    Signed-off-by: Wojciech Szarański <[email protected]>
    wszaranski committed Mar 27, 2024
    Configuration menu
    Copy the full SHA
    bc4b8b2 View commit details
    Browse the repository at this point in the history