You've already forked top-wallpaper
ALL SORTS OF THINGS
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user