status-go icon indicating copy to clipboard operation
status-go copied to clipboard

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

Open Juneezee opened this issue 3 years ago • 5 comments
trafficstars

A testing cleanup.

This pull request replaces ioutil.TempDir with t.TempDir. We can use the T.TempDir function from the testing package to create temporary directory. The directory created by T.TempDir is automatically removed when the test and all its subtests complete.

This saves us at least 2 lines (error check, and cleanup) on every instance, or in some cases adds cleanup that we forgot.

Reference: https://pkg.go.dev/testing#T.TempDir

func TestFoo(t *testing.T) {
	// before
	tmpDir, err := ioutil.TempDir("", "")
	require.NoError(t, err)
	defer os.RemoveAll(tmpDir)

	// now
	tmpDir := t.TempDir()
}

Juneezee avatar Jul 08 '22 16:07 Juneezee

Hey @Juneezee, and thank you so much for making your first pull request in status-go! :heart: Please help us make your experience better by filling out this brief questionnaire https://goo.gl/forms/uWqNcVpVz7OIopXg2

status-github-bot[bot] avatar Jul 08 '22 16:07 status-github-bot[bot]

Pull Request Checklist

  • [ ] Have you updated the documentation, if impacted (e.g. docs.status.im)?
  • [ ] Have you tested changes with mobile?
  • [ ] Have you tested changes with desktop?

status-github-bot[bot] avatar Jul 08 '22 16:07 status-github-bot[bot]

Jenkins Builds

Click to see older builds (43)
:grey_question: Commit :hash: Finished (UTC) Duration Platform Result
:heavy_check_mark: 43ccad8d #1 2022-07-08 16:24:19 ~4 min linux :package:zip
:heavy_check_mark: 43ccad8d #1 2022-07-08 16:24:59 ~4 min ios :package:zip
:heavy_check_mark: 43ccad8d #1 2022-07-08 16:26:51 ~6 min android :package:aar
:heavy_check_mark: 0f29de57 #2 2022-08-05 17:00:48 ~2 min linux :package:zip
:heavy_check_mark: 0f29de57 #2 2022-08-05 17:03:04 ~4 min ios :package:zip
:heavy_check_mark: 0f29de57 #2 2022-08-05 17:03:20 ~4 min android :package:aar
:heavy_check_mark: 24294781 #3 2022-09-11 07:23:27 ~2 min linux :package:zip
:heavy_check_mark: 24294781 #3 2022-09-11 07:26:03 ~5 min android :package:aar
:heavy_check_mark: 24294781 #3 2022-09-11 07:27:30 ~6 min ios :package:zip
:heavy_check_mark: eaddb54c #4 2022-09-18 05:19:30 ~2 min linux :package:zip
:heavy_check_mark: eaddb54c #4 2022-09-18 05:22:38 ~5 min android :package:aar
:heavy_check_mark: eaddb54c #4 2022-09-18 05:23:03 ~6 min ios :package:zip
:heavy_check_mark: 10aeb3fe #5 2022-09-30 16:16:05 ~2 min linux :package:zip
:heavy_check_mark: 10aeb3fe #5 2022-09-30 16:18:35 ~5 min android :package:aar
:heavy_check_mark: 10aeb3fe #5 2022-09-30 16:18:43 ~5 min ios :package:zip
:heavy_check_mark: c07fe109 #6 2022-10-26 03:17:07 ~2 min linux :package:zip
:heavy_check_mark: c07fe109 #6 2022-10-26 03:18:52 ~4 min ios :package:zip
:heavy_check_mark: c07fe109 #6 2022-10-26 03:19:24 ~5 min android :package:aar
:heavy_check_mark: 90150963 #7 2023-01-13 11:05:29 ~1 min linux :package:zip
:heavy_check_mark: 90150963 #7 2023-01-13 11:08:32 ~4 min android :package:aar
:heavy_check_mark: 90150963 #7 2023-01-13 11:08:46 ~5 min ios :package:zip
:heavy_multiplication_x: 90150963 #7 2023-01-13 11:21:19 ~17 min tests :page_facing_up:log
:x: bcd56e74 #8 2023-02-18 06:33:59 ~23 sec ios :page_facing_up:log
:heavy_check_mark: bcd56e74 #8 2023-02-18 06:34:53 ~1 min linux :package:zip
:heavy_check_mark: bcd56e74 #8 2023-02-18 06:37:31 ~4 min android :package:aar
:heavy_multiplication_x: bcd56e74 #8 2023-02-18 06:56:58 ~23 min tests :page_facing_up:log
:heavy_check_mark: 9023d4af #9 2023-03-13 01:23:01 ~1 min linux :package:zip
:heavy_check_mark: 9023d4af #9 2023-03-13 01:25:54 ~4 min ios :package:zip
:heavy_check_mark: 9023d4af #9 2023-03-13 01:26:17 ~4 min android :package:aar
:heavy_multiplication_x: 9023d4af #9 2023-03-13 01:43:00 ~21 min tests :page_facing_up:log
:heavy_check_mark: c297f79c #10 2023-04-16 08:45:50 ~2 min linux :package:zip
:heavy_check_mark: c297f79c #10 2023-04-16 08:47:13 ~4 min android :package:aar
:heavy_check_mark: c297f79c #10 2023-04-16 08:47:29 ~4 min ios :package:zip
:heavy_check_mark: c297f79c #10 2023-04-16 08:54:30 ~11 min tests :page_facing_up:log
:heavy_check_mark: c297f79c #13 2023-04-26 14:47:50 ~2 min linux :package:zip
:heavy_check_mark: c297f79c #13 2023-04-26 14:50:30 ~5 min android :package:aar
:heavy_check_mark: c297f79c #13 2023-04-26 14:56:41 ~11 min tests :page_facing_up:log
:x: cf6a69cf #11 2023-04-21 13:43:41 ~46 sec ios :page_facing_up:log
:heavy_check_mark: cf6a69cf #11 2023-04-21 13:45:37 ~2 min linux :package:zip
:heavy_check_mark: cf6a69cf #11 2023-04-21 13:47:30 ~4 min android :package:aar
:heavy_check_mark: cf6a69cf #11 2023-04-21 13:54:40 ~11 min tests :page_facing_up:log
:x: cf6a69cf #12 2023-04-21 16:51:17 ~30 sec ios :page_facing_up:log
:x: cf6a69cf #13 2023-04-21 21:51:57 ~10 sec ios :page_facing_up:log
:grey_question: Commit :hash: Finished (UTC) Duration Platform Result
:heavy_check_mark: 81faf852 #12 2023-04-26 13:55:56 ~2 min linux :package:zip
:heavy_check_mark: 81faf852 #14 2023-04-26 13:57:52 ~4 min ios :package:zip
:heavy_check_mark: 81faf852 #12 2023-04-26 13:57:57 ~4 min android :package:aar
:heavy_multiplication_x: 81faf852 #12 2023-04-26 14:03:32 ~10 min tests :page_facing_up:log
:heavy_check_mark: 47b74c4c #14 2023-04-26 15:04:50 ~2 min linux :package:zip
:heavy_check_mark: 47b74c4c #16 2023-04-26 15:05:10 ~3 min ios :package:zip
:heavy_check_mark: 47b74c4c #14 2023-04-26 15:06:09 ~4 min android :package:aar
:heavy_check_mark: 47b74c4c #14 2023-04-26 15:14:19 ~12 min tests :page_facing_up:log

status-im-auto avatar Jul 08 '22 16:07 status-im-auto

Rebased onto develop.

Juneezee avatar Aug 05 '22 16:08 Juneezee

Rebased onto develop.

Juneezee avatar Sep 11 '22 07:09 Juneezee

Rebased onto develop.

Juneezee avatar Oct 26 '22 03:10 Juneezee

Hello @Samyoul @jrainville @osmaczko. I apologize for the explicit mention, but I wanted to follow up on this pull request I created some time ago.

I would be grateful if you could take some time to review the changes and provide me with your feedback. If there are any specific concerns or questions you have about the changes, I am more than willing to help address them.

Thank you for your time and consideration. I truly appreciate it. :heart:

Juneezee avatar Apr 21 '23 14:04 Juneezee

@Juneezee FYI in future the best way to get a review is to select some reviewers for your PR. You can just use the suggested reviewers if you are unsure who to ask.

Screenshot 2023-04-21 at 17 57 22

Samyoul avatar Apr 21 '23 17:04 Samyoul

@Juneezee FYI in future the best way to get a review is to select some reviewers for your PR. You can just use the suggested reviewers if you are unsure who to ask.

To assign a reviewer to a pull request, you will need write access to the repository. Source: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review

@Samyoul I don't have write access, so I can't assign reviewers 😥. The suggested reviewers feature is also not available for outside contributors

image

Juneezee avatar Apr 21 '23 18:04 Juneezee

@Juneezee ah I see. Then do exactly as you've done here, let someone know there's a PR for review

Samyoul avatar Apr 21 '23 18:04 Samyoul

@Juneezee If you are having trouble with merging this PR, try rebasing against develop, force push and check if jenkins/prs/ios passes. I've restarted this test a number of times and it keeps failing, so I wonder if there is a change in develop that would fix this.

Samyoul avatar Apr 26 '23 12:04 Samyoul

@Samyoul All the tests finally passed :smile: Please take a look again. Thank you.

Juneezee avatar Apr 26 '23 15:04 Juneezee

@Juneezee are you able to merge or do you not have those permissions? If you do have the permissions feel free to merge, otherwise I will merge this for you.

Samyoul avatar Apr 26 '23 16:04 Samyoul

@Samyoul I don't have the permission to merge. Please merge it for me. Thank you

image

Juneezee avatar Apr 26 '23 16:04 Juneezee

Ok @Juneezee all done, thank you for your PR. I hope to see some more from you in the future. And hopefully they will take less than a year to get merged 😆

Samyoul avatar Apr 26 '23 20:04 Samyoul