package upstream_test

import (
	"strings"
	"testing"

	"github.com/herbygillot/dockhand/internal/macports"
	"github.com/herbygillot/dockhand/internal/macports/portsource"
	"github.com/herbygillot/dockhand/internal/upstream"
	"github.com/stretchr/testify/require"
)

func TestArchitectureArchiveUsesActualGitSource(t *testing.T) {
	port := githubPort()
	port.Options["fetch.type"] = "git"
	port.Options["git.url"] = "https://github.com/fork/project.git"
	catalog := &archiving{}
	service := &upstream.Service{Catalogs: map[portsource.Forge]upstream.Catalog{portsource.GitHub: catalog}}
	_, err := service.SourceArchive(t.Context(), macports.PortInfo{Name: "tool", Version: "1.0", Options: port.Options}, strings.Repeat("a", 40), t.TempDir())
	require.NoError(t, err)
	require.Equal(t, "fork/project", catalog.name, "archive must come from the actual fetched Git repository")
}
