chore: CI fixes

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2025-04-06 12:08:43 +02:00
parent aa7157e27c
commit 9ed3769765
4 changed files with 9 additions and 5 deletions

View File

@@ -72,7 +72,7 @@ func TestRun(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithCancel(t.Context())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if tc.config != "" {

View File

@@ -16,6 +16,7 @@
package textfile_test
import (
"context"
"fmt"
"io"
"log/slog"
@@ -44,7 +45,7 @@ func TestMultipleDirectories(t *testing.T) {
})
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
require.NoError(t, collectors.Build(t.Context(), logger))
require.NoError(t, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric)
got := ""
@@ -81,7 +82,7 @@ func TestDuplicateFileName(t *testing.T) {
})
collectors := collector.New(map[string]collector.Collector{textfile.Name: textFileCollector})
require.NoError(t, collectors.Build(t.Context(), logger))
require.NoError(t, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric)
got := ""

View File

@@ -16,6 +16,7 @@
package config
import (
"context"
"crypto/tls"
"fmt"
"io"
@@ -91,6 +92,7 @@ func NewConfigFileResolver(file string) (*Resolver, error) {
)
if strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://") {
//nolint:sloglint // we do not have an logger yet
slog.Warn("Loading configuration file from URL is deprecated and will be removed in 0.31.0. Use a local file instead.")
fileBytes, err = readFromURL(file)
@@ -142,7 +144,7 @@ func readFromURL(file string) ([]byte, error) {
client := &http.Client{Transport: tr}
req, err := http.NewRequest(http.MethodGet, file, nil)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, file, nil)
if err != nil {
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
}

View File

@@ -16,6 +16,7 @@
package testutils
import (
"context"
"errors"
"io"
"log/slog"
@@ -47,7 +48,7 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co
}
collectors := collector.New(map[string]collector.Collector{name: c})
require.NoError(b, collectors.Build(b.Context(), logger))
require.NoError(b, collectors.Build(context.Background(), logger))
metrics := make(chan prometheus.Metric)