1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

24 lines
564 B
Go
Raw Normal View History

2017-07-23 16:27:46 -03:00
// 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)
2017-07-23 16:27:46 -03:00
current, err := os.Getwd()
assert.NoError(t, err)
assert.NoError(t, os.Chdir(folder))
2017-07-23 16:27:46 -03:00
return folder, func() {
assert.NoError(t, os.Chdir(current))
2017-07-23 16:27:46 -03:00
}
}