1
0
mirror of https://github.com/regclient/regclient.git synced 2025-04-18 22:44:00 +03:00
regclient/repo_test.go
Brandon Mitchell 1eb1ea4b34
Feat: Refactor logging to use log/slog
This updates the regclient Go library.
Existing users of logrus will continue to work using a logrus handler to slog.
Updates to the various commands will be made in a future commit.

Signed-off-by: Brandon Mitchell <git@bmitch.net>
2024-11-10 17:14:57 -05:00

28 lines
677 B
Go

package regclient
import (
"context"
"errors"
"log/slog"
"os"
"testing"
"time"
"github.com/regclient/regclient/types/errs"
)
func TestRepoList(t *testing.T) {
ctx := context.Background()
log := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelWarn}))
delayInit, _ := time.ParseDuration("0.05s")
delayMax, _ := time.ParseDuration("0.10s")
rc := New(
WithSlog(log),
WithRetryDelay(delayInit, delayMax),
)
_, err := rc.RepoList(ctx, "registry.example.com/path")
if !errors.Is(err, errs.ErrParsingFailed) {
t.Errorf("RepoList unexpected error on hostname with a path: expected %v, received %v", errs.ErrParsingFailed, err)
}
}