loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add unit test for `HashAvatar` (#25662)

- Add 100% unit test for this function.

---------

Co-authored-by: Gusted <postmaster@gusted.xyz>

authored by

Earl Warren
Gusted
and committed by
GitHub
43c9a84a ff140d40

+26
+26
modules/avatar/hash_test.go
··· 1 + // Copyright 2023 The Gitea Authors. All rights reserved. 2 + // SPDX-License-Identifier: MIT 3 + 4 + package avatar_test 5 + 6 + import ( 7 + "bytes" 8 + "image" 9 + "image/png" 10 + "testing" 11 + 12 + "code.gitea.io/gitea/modules/avatar" 13 + 14 + "github.com/stretchr/testify/assert" 15 + ) 16 + 17 + func Test_HashAvatar(t *testing.T) { 18 + myImage := image.NewRGBA(image.Rect(0, 0, 32, 32)) 19 + var buff bytes.Buffer 20 + png.Encode(&buff, myImage) 21 + 22 + assert.EqualValues(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes())) 23 + assert.EqualValues(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes())) 24 + assert.EqualValues(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes())) 25 + assert.EqualValues(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{})) 26 + }