1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/internal/testlib/mktemp.go
Carlos Alexandro Becker 979f8632b7
refactor: use require on all tests (#1839)
* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-06 12:48:04 +00:00

24 lines
569 B
Go

// Package testlib contains test helpers for goreleaser tests.
package testlib
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
)
// 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")
require.NoError(t, err)
current, err := os.Getwd()
require.NoError(t, err)
require.NoError(t, os.Chdir(folder))
return folder, func() {
require.NoError(t, os.Chdir(current))
}
}