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

This commit is contained in:
2026-01-21 21:48:00 -05:00
parent e489896af2
commit e16bcc1780

View File

@@ -1,7 +1,6 @@
package reddit
import (
"fmt"
"net/http"
"net/http/httptest"
"strings"
@@ -50,12 +49,9 @@ func TestGetLatestImage(t *testing.T) {
defer server.Close()
// Custom httpGet function for testing
httpGet := func(url string) (*http.Response, error) {
if strings.Contains(url, "/r/wallpaper/.json") {
httpGet := func() (*http.Response, error) {
return http.Get(server.URL + "/r/wallpaper/.json")
}
return nil, fmt.Errorf("unexpected URL: %s", url)
}
// Test the function
imageURL, err := GetLatestImage(httpGet)