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

Add unit test for HashAvatar #25662

Merged
merged 3 commits into from
Jul 4, 2023
Merged

Conversation

earl-warren
Copy link
Contributor

  • Add 100% unit test for this function.

- Add 100% unit test for this function.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jul 3, 2023
@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 3, 2023
@@ -0,0 +1,26 @@
// Copyright 2023 The Forgejo Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2023 The Forgejo Authors. All rights reserved.
// Copyright 2023 The Gitea Authors. All rights reserved.

I think the CI won't pass otherwise.

Copy link
Member

@techknowlogick techknowlogick Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a point of clarification, will you be able to provide the copyright assignment? By introducing code from another project without the copyright assignment it raises many questions including "are we required to add the notice to the license file in the root of the git directory", among others.
Edit: this isn't anything new and has been a part of our CI verification for years.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to just do it as with other gogs code ...
... two lines

Copy link
Contributor

@wxiaoguang wxiaoguang Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think it makes sense to add more and more headers.

Otherwise I would think it's also right to add my personal name to this header like "Copyright the Gitea Authors, Copyright wxiaoguang"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we are talking about projekt's and not about individual contributors ... but i get your concern

Comment on lines +22 to +25
assert.EqualValues(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes()))
assert.EqualValues(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes()))
assert.EqualValues(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes()))
assert.EqualValues(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there multiple test cases? HashAvatar has no conditional code so every call has 100% coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to HashAvatar's comment, they are for different cases:

  • 1 & 8 : different id, different hash
  • 1024, buff.Bytes() & 1024, []byte{}: different content, different hash

ps: actually the test could be simplified by removing the myImage, because HashAvatar can be tested with byte slice directly.

Co-authored-by: delvh <dev.lh@web.de>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jul 4, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 4, 2023
@6543 6543 added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 4, 2023
@6543 6543 enabled auto-merge (squash) July 4, 2023 12:15
@6543 6543 merged commit 43c9a84 into go-gitea:main Jul 4, 2023
@GiteaBot GiteaBot added this to the 1.21.0 milestone Jul 4, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Jul 4, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jul 5, 2023
* giteaofficial/main: (22 commits)
  [skip ci] Updated translations via Crowdin
  Replace `interface{}` with `any` (go-gitea#25686)
  Several fixes for mobile UI (go-gitea#25634)
  Add elapsed time on debug for slow git commands (go-gitea#25642)
  some less naked returns (go-gitea#25682)
  Prevent duplicate image loading (go-gitea#25675)
  Add unit test for `HashAvatar` (go-gitea#25662)
  Fix the nil pointer when assigning issues to projects (go-gitea#25665)
  Actions list enhancements (go-gitea#25601)
  Fix issues indexer document mapping (go-gitea#25619)
  Fix show more for image on diff page (go-gitea#25672)
  Prevent SVG shrinking (go-gitea#25652)
  Log the real reason when authentication fails (but don't show the user) (go-gitea#25414)
  Add unit test for repository collaboration (go-gitea#25640)
  Fix UI misalignment on user setting page (go-gitea#25629)
  [skip ci] Updated translations via Crowdin
  Correct translation wrong format (go-gitea#25643)
  Add direct serving of package content (go-gitea#25543)
  Fix bug when change user name (go-gitea#25637)
  Make "cancel" buttons have proper type in modal forms (go-gitea#25618)
  ...
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants