chore(): increase test coverage and update dependencies
Some checks are pending
ci/woodpecker/pr/pr Pipeline is pending

This commit is contained in:
2025-12-18 23:12:27 +01:00
parent e779c5a38b
commit 2d1aa62c61
15 changed files with 384 additions and 74 deletions

View File

@@ -2,7 +2,6 @@ package woodpecker
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
@@ -17,19 +16,19 @@ func QueueInfo(cfg *config.Config, target interface{}) error {
apiRoute := fmt.Sprintf("%s/api/queue/info", cfg.WoodpeckerInstance)
req, err := http.NewRequest(http.MethodGet, apiRoute, nil)
if err != nil {
return errors.New(fmt.Sprintf("Could not create queue request: %s", err.Error()))
return fmt.Errorf("Could not create queue request: %s", err.Error())
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", cfg.WoodpeckerApiToken))
resp, err := http.DefaultClient.Do(req)
if err != nil {
return errors.New(fmt.Sprintf("Could not query queue info: %s", err.Error()))
return fmt.Errorf("Could not query queue info: %s", err.Error())
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return errors.New(fmt.Sprintf("Error from queue info api: %s", resp.Status))
return fmt.Errorf("Error from queue info api: %s", resp.Status)
}
return json.NewDecoder(resp.Body).Decode(target)
@@ -40,7 +39,7 @@ func CheckPending(cfg *config.Config) (int, error) {
queueInfo := new(models.QueueInfo)
err := QueueInfo(cfg, queueInfo)
if err != nil {
return 0, errors.New(fmt.Sprintf("Error from QueueInfo: %s", err.Error()))
return 0, fmt.Errorf("Error from QueueInfo: %s", err.Error())
}
count := 0
if queueInfo.Stats.PendingCount > 0 {
@@ -64,7 +63,7 @@ func CheckRunning(cfg *config.Config) (int, error) {
queueInfo := new(models.QueueInfo)
err := QueueInfo(cfg, queueInfo)
if err != nil {
return 0, errors.New(fmt.Sprintf("Error from QueueInfo: %s", err.Error()))
return 0, fmt.Errorf("Error from QueueInfo: %s", err.Error())
}
count := 0
if queueInfo.Stats.RunningCount > 0 {