-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add unit test for HashAvatar
#25662
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The Forgejo Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package avatar_test | ||
Check failure on line 4 in modules/avatar/hash_test.go GitHub Actions / lint-backend
|
||
|
||
import ( | ||
"bytes" | ||
"image" | ||
"image/png" | ||
"testing" | ||
|
||
"code.gitea.io/gitea/modules/avatar" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_HashAvatar(t *testing.T) { | ||
myImage := image.NewRGBA(image.Rect(0, 0, 32, 32)) | ||
var buff bytes.Buffer | ||
png.Encode(&buff, myImage) | ||
|
||
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{})) | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are there multiple test cases? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to
ps: actually the test could be simplified by removing the |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the CI won't pass otherwise.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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