disable gravatar in test (#32529)

When running e2e tests on flaky networks, gravatar can cause a timeout
and test failures. Turn off, and populate avatars on e2e test suite run
to make them reliable.
This commit is contained in:
Rowan Bohde 2024-11-20 22:30:48 -06:00 committed by GitHub
parent d11f8d24b0
commit 9ac74a1a40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 89 additions and 92 deletions

View File

@ -1,7 +1,7 @@
- -
id: 1 id: 1
setting_key: 'picture.disable_gravatar' setting_key: 'picture.disable_gravatar'
setting_value: 'false' setting_value: 'true'
version: 1 version: 1
created: 1653533198 created: 1653533198
updated: 1653533198 updated: 1653533198

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,6 @@
package repository package repository
import ( import (
"crypto/md5"
"fmt"
"strconv" "strconv"
"testing" "testing"
"time" "time"
@ -125,15 +123,12 @@ func TestPushCommits_AvatarLink(t *testing.T) {
}, },
} }
setting.GravatarSource = "https://secure.gravatar.com/avatar"
setting.OfflineMode = true
assert.Equal(t, assert.Equal(t,
"/avatars/avatar2?size="+strconv.Itoa(28*setting.Avatar.RenderedSizeFactor), "/avatars/ab53a2911ddf9b4817ac01ddcd3d975f?size="+strconv.Itoa(28*setting.Avatar.RenderedSizeFactor),
pushCommits.AvatarLink(db.DefaultContext, "user2@example.com")) pushCommits.AvatarLink(db.DefaultContext, "user2@example.com"))
assert.Equal(t, assert.Equal(t,
fmt.Sprintf("https://secure.gravatar.com/avatar/%x?d=identicon&s=%d", md5.Sum([]byte("nonexistent@example.com")), 28*setting.Avatar.RenderedSizeFactor), "/assets/img/avatar_default.png",
pushCommits.AvatarLink(db.DefaultContext, "nonexistent@example.com")) pushCommits.AvatarLink(db.DefaultContext, "nonexistent@example.com"))
} }

View File

@ -18,6 +18,7 @@ import (
func TestRepository_ContributorsGraph(t *testing.T) { func TestRepository_ContributorsGraph(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase()) assert.NoError(t, unittest.PrepareTestDatabase())
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}) repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
assert.NoError(t, repo.LoadOwner(db.DefaultContext)) assert.NoError(t, repo.LoadOwner(db.DefaultContext))
mockCache, err := cache.NewStringCache(setting.Cache{}) mockCache, err := cache.NewStringCache(setting.Cache{})
@ -46,7 +47,7 @@ func TestRepository_ContributorsGraph(t *testing.T) {
assert.EqualValues(t, &ContributorData{ assert.EqualValues(t, &ContributorData{
Name: "Ethan Koenig", Name: "Ethan Koenig",
AvatarLink: "https://secure.gravatar.com/avatar/b42fb195faa8c61b8d88abfefe30e9e3?d=identicon", AvatarLink: "/assets/img/avatar_default.png",
TotalCommits: 1, TotalCommits: 1,
Weeks: map[int64]*WeekData{ Weeks: map[int64]*WeekData{
1511654400000: { 1511654400000: {

View File

@ -107,7 +107,7 @@ func TestE2e(t *testing.T) {
cmd.Stdout = &stdout cmd.Stdout = &stdout
cmd.Stderr = &stderr cmd.Stderr = &stderr
err := cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
// Currently colored output is conflicting. Using Printf until that is resolved. // Currently colored output is conflicting. Using Printf until that is resolved.
fmt.Printf("%v", stdout.String()) fmt.Printf("%v", stdout.String())