1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-01 13:07:49 +02:00
Carlos Alexandro Becker 57753af876
testlib
2017-07-23 16:27:46 -03:00

25 lines
580 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()) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(err)
current, err := os.Getwd()
assert.NoError(err)
assert.NoError(os.Chdir(folder))
return folder, func() {
assert.NoError(os.Chdir(current))
}
}