<commit_before>package checksums

import (
	"io/ioutil"
	"path/filepath"
	"testing"

	"github.com/goreleaser/goreleaser/config"
	"github.com/goreleaser/goreleaser/context"
	"github.com/goreleaser/goreleaser/internal/artifact"
	"github.com/stretchr/testify/assert"
)

func TestDescription(t *testing.T) {
	assert.NotEmpty(t, Pipe{}.String())
}

func TestPipe(t *testing.T) {
	var binary = "binary"
	var checksums = binary + "_checksums.txt"
	folder, err := ioutil.TempDir("", "goreleasertest")
	assert.NoError(t, err)
	var file = filepath.Join(folder, binary)
	assert.NoError(t, ioutil.WriteFile(file, []byte("some string"), 0644))
	var ctx = context.New(
		config.Project{
			Dist:        folder,
			ProjectName: binary,
			Checksum: config.Checksum{
				NameTemplate: "{{ .ProjectName }}_checksums.txt",
			},
		},
	)
	ctx.Artifacts.Add(artifact.Artifact{
		Name: binary,
		Path: file,
		Type: artifact.UploadableBinary,
	})
	assert.NoError(t, Pipe{}.Run(ctx))
	var artifacts []string
	for _, a := range ctx.Artifacts.List() {
		artifacts = append(artifacts, a.Name)
	}
	assert.Contains(t, artifacts, checksums, binary)
	bts, err := ioutil.ReadFile(filepath.Join(folder, checksums))
	assert.NoError(t, err)
	assert.Equal(t, "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc  binary\n", string(bts))
}
<commit_msg>test: added env to pipe tests<commit_after>package checksums

import (
	"io/ioutil"
	"path/filepath"
	"testing"

	"github.com/goreleaser/goreleaser/config"
	"github.com/goreleaser/goreleaser/context"
	"github.com/goreleaser/goreleaser/internal/artifact"
	"github.com/stretchr/testify/assert"
)

func TestDescription(t *testing.T) {
	assert.NotEmpty(t, Pipe{}.String())
}

func TestPipe(t *testing.T) {
	var binary = "binary"
	var checksums = binary + "_bar_checksums.txt"
	folder, err := ioutil.TempDir("", "goreleasertest")
	assert.NoError(t, err)
	var file = filepath.Join(folder, binary)
	assert.NoError(t, ioutil.WriteFile(file, []byte("some string"), 0644))
	var ctx = context.New(
		config.Project{
			Dist:        folder,
			ProjectName: binary,
			Checksum: config.Checksum{
				NameTemplate: "{{ .ProjectName }}_{{ .Env.FOO }}_checksums.txt",
			},
		},
	)
	ctx.Env = map[string]string{"FOO": "bar"}
	ctx.Artifacts.Add(artifact.Artifact{
		Name: binary,
		Path: file,
		Type: artifact.UploadableBinary,
	})
	assert.NoError(t, Pipe{}.Run(ctx))
	var artifacts []string
	for _, a := range ctx.Artifacts.List() {
		artifacts = append(artifacts, a.Name)
	}
	assert.Contains(t, artifacts, checksums, binary)
	bts, err := ioutil.ReadFile(filepath.Join(folder, checksums))
	assert.NoError(t, err)
	assert.Equal(t, "61d034473102d7dac305902770471fd50f4c5b26f6831a56dd90b5184b3c30fc  binary\n", string(bts))
}

{'fraction_non_alphanumeric': 0.15120525931336742, 'fraction_numerical': 0.03579254930606282, 'mean_word_length': 4.9030172413793105, 'pattern_counts': {'":': 1, '<': 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': '5919962', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1082, 'n_words': 181}