From 92d4be2f2355279a4eebe8937102a03102c3d9fb Mon Sep 17 00:00:00 2001 From: Ron Rise Date: Mon, 21 Apr 2025 23:04:24 -0400 Subject: [PATCH] ALL SORTS OF THINGS --- .gitlab-ci.yml | 9 ++++----- http/handler.go | 4 +++- reddit/client.go | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 441957f..d34ceea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,12 @@ stages: - - noop + - Testing - build -noop: - stage: noop - script: - - echo "This is a no-op job" include: + - component: $CI_SERVER_FQDN/shared/blueprints/golang-tests@v1.2.0 + rules: + - if: '$CI_COMMIT_BRANCH' - component: $CI_SERVER_FQDN/shared/blueprints/docker-build@v1.2.0 rules: - if: '$CI_COMMIT_TAG' diff --git a/http/handler.go b/http/handler.go index ad70a55..ab9edc6 100644 --- a/http/handler.go +++ b/http/handler.go @@ -22,7 +22,9 @@ func Get(c echo.Context) error { if err != nil || latestImageVal == "" { c.Logger().Info("Fetching latest image") - latestImageVal, err = client.GetLatestImage() + latestImageVal, err = client.GetLatestImage(func(url string) (*http.Response, error) { + return http.Get(url) + }) if err != nil { return c.String(http.StatusInternalServerError, "Error fetching latest image") } diff --git a/reddit/client.go b/reddit/client.go index 7074e50..87495c9 100644 --- a/reddit/client.go +++ b/reddit/client.go @@ -54,9 +54,9 @@ type redditResponse struct { } `json:"data"` } -func GetLatestImage() (string, error) { +func GetLatestImage(httpGet func(url string) (*http.Response, error)) (string, error) { - response, err := http.Get("https://www.reddit.com/r/wallpaper/.json") + response, err := httpGet("https://www.reddit.com/r/wallpaper/.json") if err != nil { return "", err }