1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/internal/testlib/mktemp.go
Carlos Alexandro Becker d85a9001ec
removing all assert.New because vet shadow complains about this now
aaaaaaaaaaarhhhhhhhhgttt
2017-09-26 19:24:49 -03:00

24 lines
564 B
Go

// Package testlib contains test helpers for goreleaser tests.
package testlib
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
// Mktmp creates a new tempdir, cd into it and provides a back function that
// cd into the previous directory.
func Mktmp(t *testing.T) (folder string, back func()) {
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(t, err)
current, err := os.Getwd()
assert.NoError(t, err)
assert.NoError(t, os.Chdir(folder))
return folder, func() {
assert.NoError(t, os.Chdir(current))
}
}