<commit_before>package build

import (
	"testing"

	"github.com/goreleaser/goreleaser/config"
	"github.com/goreleaser/goreleaser/context"
	"github.com/goreleaser/goreleaser/pipeline/defaults"
	"github.com/stretchr/testify/assert"
)

func TestNameFor(t *testing.T) {
	assert := assert.New(t)

	var config = config.Project{
		Archive: config.Archive{
			NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Tag}}_{{.Version}}",
			Replacements: map[string]string{
				"darwin": "Darwin",
				"amd64":  "x86_64",
			},
		},
		Build: config.Build{
			Binary: "test",
		},
	}
	var ctx = &context.Context{
		Config:  config,
		Version: "1.2.3",
		Git: context.GitInfo{
			CurrentTag: "v1.2.3",
		},
	}

	name, err := nameFor(ctx, buildTarget{"darwin", "amd64", ""})
	assert.NoError(err)
	assert.Equal("test_Darwin_x86_64_v1.2.3_1.2.3", name)
}

func TestInvalidNameTemplate(t *testing.T) {
	assert := assert.New(t)

	var config = config.Project{
		Archive: config.Archive{
			NameTemplate: "{{.Binary}_{{.Os}}_{{.Arch}}_{{.Version}}",
		},
		Build: config.Build{
			Binary: "test",
		},
	}
	var ctx = &context.Context{
		Config: config,
		Git: context.GitInfo{
			CurrentTag: "v1.2.3",
		},
	}

	_, err := nameFor(ctx, buildTarget{"darwin", "amd64", ""})
	assert.Error(err)
}

func TestNameDefaltTemplate(t *testing.T) {
	assert := assert.New(t)
	var ctx = &context.Context{
		Config: config.Project{
			Archive: config.Archive{
				NameTemplate: defaults.NameTemplate,
			},
			Build: config.Build{
				Binary: "test",
			},
		},
		Version: "1.2.3",
	}
	for key, target := range map[string]buildTarget{
		"test_darwin_amd64": {"darwin", "amd64", ""},
		"test_linux_arm64":  {"linux", "arm64", ""},
		"test_linux_armv7":  {"linux", "arm", "7"},
	} {
		t.Run(key, func(t *testing.T) {
			name, err := nameFor(ctx, target)
			assert.NoError(err)
			assert.Equal(key, name)
		})
	}

}
<commit_msg>fix test<commit_after>package build

import (
	"testing"

	"github.com/goreleaser/goreleaser/config"
	"github.com/goreleaser/goreleaser/context"
	"github.com/goreleaser/goreleaser/pipeline/defaults"
	"github.com/stretchr/testify/assert"
)

func TestNameFor(t *testing.T) {
	assert := assert.New(t)

	var config = config.Project{
		Archive: config.Archive{
			NameTemplate: "{{.Binary}}_{{.Os}}_{{.Arch}}_{{.Tag}}_{{.Version}}",
			Replacements: map[string]string{
				"darwin": "Darwin",
				"amd64":  "x86_64",
			},
		},
		Build: config.Build{
			Binary: "test",
		},
	}
	var ctx = &context.Context{
		Config:  config,
		Version: "1.2.3",
		Git: context.GitInfo{
			CurrentTag: "v1.2.3",
		},
	}

	name, err := nameFor(ctx, buildTarget{"darwin", "amd64", ""})
	assert.NoError(err)
	assert.Equal("test_Darwin_x86_64_v1.2.3_1.2.3", name)
}

func TestInvalidNameTemplate(t *testing.T) {
	assert := assert.New(t)

	var config = config.Project{
		Archive: config.Archive{
			NameTemplate: "{{.Binary}_{{.Os}}_{{.Arch}}_{{.Version}}",
		},
		Build: config.Build{
			Binary: "test",
		},
	}
	var ctx = &context.Context{
		Config: config,
		Git: context.GitInfo{
			CurrentTag: "v1.2.3",
		},
	}

	_, err := nameFor(ctx, buildTarget{"darwin", "amd64", ""})
	assert.Error(err)
}

func TestNameDefaltTemplate(t *testing.T) {
	assert := assert.New(t)
	var ctx = &context.Context{
		Config: config.Project{
			Archive: config.Archive{
				NameTemplate: defaults.NameTemplate,
			},
			Build: config.Build{
				Binary: "test",
			},
		},
		Version: "1.2.3",
	}
	for key, target := range map[string]buildTarget{
		"test_1.2.3_darwin_amd64": {"darwin", "amd64", ""},
		"test_1.2.3_linux_arm64":  {"linux", "arm64", ""},
		"test_1.2.3_linux_armv7":  {"linux", "arm", "7"},
	} {
		t.Run(key, func(t *testing.T) {
			name, err := nameFor(ctx, target)
			assert.NoError(err)
			assert.Equal(key, name)
		})
	}

}

{'fraction_non_alphanumeric': 0.1963482402752051, 'fraction_numerical': 0.024609685101878803, 'mean_word_length': 3.8963730569948187, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3191868', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1511, 'n_words': 249}