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

all: use T.TempDir to create temporary test directories #24633

Merged
merged 2 commits into from
Apr 8, 2022
Merged

all: use T.TempDir to create temporary test directories #24633

merged 2 commits into from
Apr 8, 2022

Commits on Apr 4, 2022

  1. test: use T.TempDir to create temporary test directory

    This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
    directory created by `t.TempDir` is automatically removed when the test
    and all its subtests complete.
    
    Prior to this commit, temporary directory created using `ioutil.TempDir`
    needs to be removed manually by calling `os.RemoveAll`, which is omitted
    in some tests. The error handling boilerplate e.g.
    	defer func() {
    		if err := os.RemoveAll(dir); err != nil {
    			t.Fatal(err)
    		}
    	}
    is also tedious, but `t.TempDir` handles this for us nicely.
    
    Reference: https://pkg.go.dev/testing#T.TempDir
    Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
    Juneezee committed Apr 4, 2022
    Configuration menu
    Copy the full SHA
    21bdd01 View commit details
    Browse the repository at this point in the history
  2. test: remove unnecessary tt.Cleanup line

    Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
    Juneezee committed Apr 4, 2022
    Configuration menu
    Copy the full SHA
    e7d4e74 View commit details
    Browse the repository at this point in the history