/*
  * Copyright 2026 Oleg Borodin <onborodin@gmail.com>
 *
 *
*/

package repocli

import (
	"github.com/stretchr/testify/require"

	"context"
	"fmt"
	"testing"
	"time"
)

func xxxTestClientGetToken(t *testing.T) {
	var token string
	var err error
	{
		cli := NewClient(nil, nil)
		//cli.UseMiddleware(NewBasicAuthMiddleware("xxxxxxx", "xxxxxxxxxx"))
		ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
		token, err = cli.GetToken(ctx, "https://auth.docker.io/token")
		require.NoError(t, err)

	}
	fmt.Printf("Token: %s\n", token)
	{
		rawrepo := "docker.io/onborodin/toolbox:0.18"
		cli := NewClient(nil, nil)
		//cli.UseMiddleware(NewBearerAuthMiddleware(token))
		ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
		id, loc, err := cli.GetUpload(ctx, rawrepo)
		require.NoError(t, err)
		fmt.Printf("Upload ID: %s\n", id)
		fmt.Printf("Upload Location: %s\n", loc)
	}

}
