Simplify httpGet function in client_test.go for cleaner code
All checks were successful
🚨 Test Code Base / 🧹 Lint (push) Successful in 58s
🚨 Test Code Base / 🔍 🐹 Go Tests (push) Successful in 1m10s
🏗️✨ Build Workflow / 🖥️ 🔨 Build (push) Successful in 4m24s

This commit is contained in:
2026-01-21 22:35:39 -05:00
parent e16bcc1780
commit 14999e412a

View File

@@ -63,13 +63,16 @@ func Fetch(ctx context.Context) {
func doFetch(rc *redis.Redis, l echo.Logger, nsfw bool, size int) {
val, err := rc.Get(rc.GetCacheKey(nsfw))
l.Info("Checking cache for Reddit image...", " nsfw=", nsfw)
if err != nil {
l.Error("Error fetching from Redis: ", err)
return
}
if val != "" {
l.Info("Reddit image fetched from cache...")
l.Info("Reddit image is in cache... skipping...")
return
}
@@ -79,8 +82,7 @@ func doFetch(rc *redis.Redis, l echo.Logger, nsfw bool, size int) {
latestImageVal, err := GetLatestImage(func() (*http.Response, error) {
jsonUrl := wallpaperURL
nsfwMode := os.Getenv("NSFW_MODE")
if nsfwMode == "true" {
if nsfw {
jsonUrl = nsfwWallpaperURL
}