<commit_before>package release

import (
	"testing"

	"github.com/goreleaser/goreleaser/pkg/config"
	"github.com/goreleaser/goreleaser/pkg/context"
	"github.com/stretchr/testify/require"
)

func TestSetupGitLab(t *testing.T) {
	t.Run("no repo", func(t *testing.T) {
		ctx := context.New(config.Project{})

		require.NoError(t, setupGitLab(ctx))
		require.Equal(t, "goreleaser", ctx.Config.Release.GitLab.Owner)
		require.Equal(t, "goreleaser", ctx.Config.Release.GitLab.Name)
	})

	t.Run("with templates", func(t *testing.T) {
		ctx := context.New(config.Project{
			Env: []string{"NAME=foo", "OWNER=bar"},
			GitLabURLs: config.GitLabURLs{
				Download: "https://{{ .Env.OWNER }}/download",
			},
			Release: config.Release{
				GitLab: config.Repo{
					Owner: "{{.Env.OWNER}}",
					Name:  "{{.Env.NAME}}",<commit_msg>test: fix scm test on forks<commit_after>package release

import (
	"testing"

	"github.com/goreleaser/goreleaser/internal/git"
	"github.com/goreleaser/goreleaser/pkg/config"
	"github.com/goreleaser/goreleaser/pkg/context"
	"github.com/stretchr/testify/require"
)

func TestSetupGitLab(t *testing.T) {
	t.Run("no repo", func(t *testing.T) {
		ctx := context.New(config.Project{})

		require.NoError(t, setupGitLab(ctx))

		repo, err := git.ExtractRepoFromConfig(ctx)
		require.NoError(t, err)
		require.Equal(t, repo.Owner, ctx.Config.Release.GitLab.Owner)
		require.Equal(t, repo.Name, ctx.Config.Release.GitLab.Name)
	})

	t.Run("with templates", func(t *testing.T) {
		ctx := context.New(config.Project{
			Env: []string{"NAME=foo", "OWNER=bar"},
			GitLabURLs: config.GitLabURLs{
				Download: "https://{{ .Env.OWNER }}/download",
			},
			Release: config.Release{
				GitLab: config.Repo{
					Owner: "{{.Env.OWNER}}",
					Name:  "{{.Env.NAME}}",
{'fraction_non_alphanumeric': 0.18274111675126903, 'fraction_numerical': 0.0, 'mean_word_length': 4.279761904761905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2342993', 'n_tokens_mistral': 779, 'n_tokens_neox': 687, 'n_words': 104}